Skip to content

Releases: Nevenall/remark-terms

2.0.0

31 Jul 21:19
bf5489c
Compare
Choose a tag to compare

remark-terms

This remark plugin parses customizable markdown for indicating special terms and phrases.

Default Syntax

Special terms are marked with 1 or 2 curly braces {}.

{term one}
{{term two}}

results in:

<span class="term-1">term one</span>
<span class="term-2">term two</span>

Terms will be parsed in most places, including headers: # Header with a {term} renders as <h1>Header with a <span class="term-1">term</span></h1>

Nested terms will also be parsed: {I am a special phrase with a {{nested}} term.} renders as <p><span class="term-1">I am a special phrase with a <span class="term-2">nested</span> term.</span></p>

Installation

npm install remark-terms

Usage

Dependencies:

const unified = require('unified')
const remarkParse = require('remark-parse')
const remarkTerms = require('remark-terms')
const stringify = require('rehype-stringify')
const remark2rehype = require('remark-rehype')

Usage:

unified()
  .use(remarkParse)
  .use(remarkTerms)
  .use(remark2rehype)
  .use(stringify)

Options

Options can be supplied to remark-terms as an [] of Configurations:

var processor = unified()
   .use(markdown)
   .use(terms, [{
      open: '{',
      close: '}',
      element: 'span',
      class: 'term-1'
   }, {
      open: '{{',
      close: '}}',
      element: 'span',
      class: 'term-2'
   }])
   .use(remark2rehype)
   .use(html)

Configurations

Configures a particular special term.

open

Required

A string that marks the start of a term.

close

Required

A string that marks the end of a special term.

element

Optional, default is span

The name of an html element as a string. This can be anything, but a flow content will probably work the best.

class

Optional, default is none

The optional name of a class to place on the element.

License

MIT © Dan Behlings

Initial Github Package

10 Jul 18:24
Compare
Choose a tag to compare

But has version parity with npm.