Skip to content

Latest commit

 

History

History
66 lines (45 loc) · 1.56 KB

README.md

File metadata and controls

66 lines (45 loc) · 1.56 KB

remark-abbr

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

Install

npm:

npm install https://github.com/Gammaalpha/remark-abbr.git

or

yarn:

yarn add https://github.com/Gammaalpha/remark-abbr.git

Use

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>

License

MIT