Socket
Socket
Sign inDemoInstall

remark-sub-super

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-sub-super

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


Version published
Maintainers
2
Created
Source

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

Keywords

FAQs

Package last updated on 27 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc