remark plugin to parse custom Markdown syntax to produce abbreviations.
It creates a new MDAST node type : "abbr".
A demo for it can be seen here
Note: Does NOT work with React Markdown
npm:
npm install https://github.com/Gammaalpha/remark-abbr.git
or
yarn:
If we have the following file, example.md
*[MDAST]:Markdown Abstract Syntax Trees
This plugin is built for the current remark-parser and uses MDAST implemented by
[remark](https://github.com/remarkjs/remark)
And the script example.js has the following code:
const fs = require("fs");
const unified = require("unified");
const remarkParse = require("remark-parse");
const remark2rehype = require("remark-rehype");
const rehypeStringify = require("rehype-stringify");
unified()
.use(remarkParse)
.use(RemarkAbbr)
.use(remark2rehype)
.use(rehypeStringify)
.process(
fs.readFileSync(`${process.cwd()}/src/example.md`),
(err: any, file: any) => console.log(String(file))
);
This would output into the following HTML:
<p>
This plugin is built for the current remark-parser and uses
<abbr title="Markdown Abstract Syntax Trees">MDAST</abbr> implemented by
<a href="https://github.com/remarkjs/remark">remark</a>
</p>