remark-abbr
v1.4.2
Published
This [remark][remark] plugin parses custom Markdown syntax to produce (HTML) abbreviations.
Downloads
5,216
Readme
remark-abbr
This remark plugin parses custom Markdown syntax to produce (HTML) abbreviations.
It introduces a new MDAST node type: "abbr".
interface abbr <: Node {
type: "abbr";
abbr: string;
reference: string;
data: {
hName: "abbr";
hProperties: {
title: string;
}
}
}
Syntax
Abbreviations are defined a bit like footnotes:
This plugin works on MDAST, a Markdown AST
implemented by [remark](https://github.com/remarkjs/remark)
*[MDAST]: Markdown Abstract Syntax Tree.
*[AST]: Abstract syntax tree
This would compile to the following HTML:
<p>This plugin works on <abbr title="Markdown Abstract Syntax Tree.">MDAST</abbr>, a Markdown <abbr title="Abstract syntax tree">AST</abbr>
implemented by <a href="https://github.com/remarkjs/remark">remark</a></p>
Installation
npm:
npm install remark-abbr
Usage
Dependencies:
const unified = require('unified')
const remarkParse = require('remark-parse')
const remarkAbbr = require('remark-abbr')
const stringify = require('rehype-stringify')
const remark2rehype = require('remark-rehype')
Usage:
unified()
.use(remarkParse)
.use(remarkAbbr)
.use(remark2rehype)
.use(stringify)
Options
options.expandFirst
Expand the first occurrence of each abbreviation in place to introduce the definition and it's definition. Further occurrences are parsed into "abbr" MDAST nodes as the plugin would normally do.
example
.use(remarkAbbr, { expandFirst: true })
given
This plugin works on MDAST.
More stuff about MDAST.
*[MDAST]: Markdown Abstract Syntax Tree
produces
<p>This plugin works on Markdown Abstract Syntax Tree (<abbr title="Markdown Abstract Syntax Tree">MDAST</abbr>).</p>
<p>More stuff about <abbr title="Markdown Abstract Syntax Tree">MDAST</abbr>.</p>"