What is markdown-it-sub?
The markdown-it-sub package is a plugin for the markdown-it Markdown parser that adds support for subscript text. This allows users to include subscript text in their Markdown documents, which is useful for scientific notation, chemical formulas, and other contexts where subscript text is needed.
What are markdown-it-sub's main functionalities?
Subscript Text
This feature allows you to render subscript text in Markdown. By using the tilde (~) syntax, you can convert text to subscript. In the example, 'H~2~O' is converted to 'H<sub>2</sub>O'.
const md = require('markdown-it')();
const sub = require('markdown-it-sub');
md.use(sub);
const result = md.render('H~2~O');
console.log(result); // Outputs: <p>H<sub>2</sub>O</p>
Other packages similar to markdown-it-sub
markdown-it-sup
The markdown-it-sup package is a plugin for the markdown-it Markdown parser that adds support for superscript text. It is similar to markdown-it-sub but focuses on superscript text instead of subscript. It uses the caret (^) syntax to convert text to superscript.
markdown-it-attrs
The markdown-it-attrs package allows you to add attributes to Markdown elements. While it does not specifically focus on subscript or superscript text, it provides a more general solution for adding custom attributes to any Markdown element, which can include styling for subscript or superscript.
markdown-it-footnote
The markdown-it-footnote package adds footnote support to the markdown-it parser. While it is not directly related to subscript text, it provides another way to include additional information in a Markdown document, similar to how subscript text is used to provide additional context.
markdown-it-sub
Subscript (<sub>
) tag plugin for markdown-it markdown parser.
v1.+ requires markdown-it
v4.+, see changelog.
H~2~0
=> H<sub>2</sub>O
Markup is based on pandoc definition. But nested markup is currently not supported.
Install
node.js, browser:
npm install markdown-it-sub --save
bower install markdown-it-sub --save
Use
var md = require('markdown-it')()
.use(require('markdown-it-sub'));
md.render('H~2~0')
Differences in browser. If you load script directly into the page, without
package system, module will add itself globally as window.markdownitSub
.
License
MIT