remark-abbr
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/remark-abbr package

1.4.2 • Public • Published

remark-abbr Build Status Coverage Status

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>"

License

MIT © Zeste de Savoir

Readme

Keywords

Package Sidebar

Install

npm i remark-abbr

Weekly Downloads

1,909

Version

1.4.2

License

MIT

Unpacked Size

13.4 kB

Total Files

5

Last publish

Collaborators

  • situphen
  • talone