1.0.20 • Published 3 years ago

remark-sub-super v1.0.20

Weekly downloads
3,269
License
MIT
Repository
github
Last release
3 years ago

remark-sub-super Build Status Coverage Status

This plugin parses custom Markdown syntax to handle subscript and superscript. It adds new nodes types to the mdast produced by remark:

  • sub
  • sup

If you are using rehype, the stringified HTML result will be sub or sup.

Syntax

~subscript~, e.g. a~i~

^superscript^, e.g. e^x^

AST (see mdast specification)

Sub (Parent) represents a subscript text.

interface Sub <: Parent {
  type: "sub";
}

Sup (Parent) represents a superscript text.

interface Sup <: Parent {
  type: "sup";
}

For example, the following markdown:

a^x^

x~i~

Yields:

{
  type: 'paragraph',
  children: [{
    type: 'text',
    value: 'a',
    children: [{
      type: 'sup',
      children: [{
        type: 'text',
        value: 'x'
      }]
    }]
  }]
},
{
  type: 'paragraph',
  children: [{
    type: 'text',
    value: 'x',
    children: [{
      type: 'sub',
      children: [{
        type: 'text',
        value: 'i'
      }]
    }]
  }]
}

Rehype

This plugin is compatible with rehype. Sub mdast nodes will become <sub>contents</sub>, Sup mdast nodes will become <sup>contents</sup>.

Installation

npm:

npm install remark-sub-super

Usage

Dependencies:

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

const remarkSubSuper = require('remark-sub-super')

Usage:

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

License

MIT © Zeste de Savoir

1.0.20

3 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

6 years ago

1.0.14

6 years ago

1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

0.0.17

7 years ago

0.0.16

7 years ago

0.0.15

7 years ago

0.0.14

7 years ago

0.0.13

7 years ago

0.0.12

7 years ago

0.0.11

7 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago