{"id":13509,"library":"markdown-it-sub","title":"markdown-it Subscript Plugin","description":"markdown-it-sub is a specialized plugin designed for the popular markdown-it parser, extending its capabilities to render subscript `<sub>` HTML tags from specific Markdown syntax. It adopts a Pandoc-like markup convention, where content enclosed in tildes (e.g., `H~2~O`) is parsed and converted into a subscript element. The current stable version is 2.0.0. While an explicit release cadence is not provided, markdown-it plugins typically maintain long-term stability and are updated primarily in response to breaking changes within the core markdown-it library or critical bug fixes. Its primary differentiator is its focused functionality on subscript rendering, offering a lightweight and standards-compliant method for incorporating mathematical or chemical notations without the complexity of full-fledged LaTeX-like rendering engines. It integrates seamlessly into existing markdown-it setups, enhancing parsing capabilities with minimal overhead. The plugin does not currently support nested subscript markup.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/markdown-it/markdown-it-sub","tags":["javascript","markdown-it-plugin","markdown-it","markdown","subscript","sub"],"install":[{"cmd":"npm install markdown-it-sub","lang":"bash","label":"npm"},{"cmd":"yarn add markdown-it-sub","lang":"bash","label":"yarn"},{"cmd":"pnpm add markdown-it-sub","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required as the core parser for this plugin to extend.","package":"markdown-it","optional":false}],"imports":[{"note":"The plugin typically exports itself as the default export for ESM usage, consistent with markdown-it plugin patterns.","wrong":"import { markdownitSub } from 'markdown-it-sub';","symbol":"markdownitSub","correct":"import markdownitSub from 'markdown-it-sub';"},{"note":"Standard CommonJS import for Node.js environments.","symbol":"markdownitSub","correct":"const markdownitSub = require('markdown-it-sub');"},{"note":"When loaded directly in a browser without a module system, the plugin attaches itself globally to the `window` object.","symbol":"window.markdownitSub","correct":"// Include <script src=\"path/to/markdown-it-sub.min.js\"></script>"}],"quickstart":{"code":"import MarkdownIt from 'markdown-it';\nimport markdownitSub from 'markdown-it-sub';\n\nconst md = MarkdownIt().use(markdownitSub);\n\nconst markdownInput = 'H~2~O is the chemical formula for water, and E=mc~2~ is Einstein\\'s famous equation.';\nconst htmlOutput = md.render(markdownInput);\n\nconsole.log(htmlOutput);\n// Expected output: <p>H<sub>2</sub>O is the chemical formula for water, and E=mc<sub>2</sub> is Einstein's famous equation.</p>","lang":"typescript","description":"Demonstrates initializing `markdown-it` and registering the subscript plugin, then rendering a Markdown string with subscript notation."},"warnings":[{"fix":"Update your `markdown-it` dependency in `package.json` to `^4.0.0` or a newer compatible version (e.g., `npm install markdown-it@^4.0.0`).","message":"When upgrading markdown-it-sub to version 1.0.0 or higher, it is mandatory to ensure that your markdown-it core library is at least version 4.0.0. Older versions of markdown-it are incompatible with `markdown-it-sub` v1.x and above.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Avoid attempting to nest subscript syntax (e.g., `A~B~C~D~`) as it will not render as intended. Simplify expressions or consider alternative rendering solutions if complex nesting is required.","message":"The plugin's Pandoc-like markup (`H~2~O`) currently does not support nested subscript expressions. Only flat subscript ranges are parsed.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'2.0.0':64 'adopt':35 'break':90 'bug':101 'cadenc':69 'capabl':24,150 'chang':91 'chemic':125 'complex':129 'compliant':119 'content':43 'convent':41 'convert':54 'core':94 'critic':100 'current':60,158 'design':14 'differenti':105 'e.g':47 'element':58 'enclos':44 'engin':138 'enhanc':148 'exist':143 'explicit':67 'extend':22 'fix':102 'fledg':133 'focus':108 'full':132 'full-fledg':131 'function':109 'h':48 'html':28 'incorpor':122 'integr':140 'javascript':163 'latex':135 'latex-lik':134 'librari':98 'lightweight':115 'like':39,136 'long':80 'long-term':79 'maintain':78 'markdown':2,7,19,32,74,96,145,165,169,171 'markdown-it':1,18,73,95,144,168 'markdown-it-plugin':164 'markdown-it-sub':6 'markup':40,162 'mathemat':123 'method':120 'minim':152 'nest':160 'notat':126 'offer':113 'overhead':153 'pandoc':38 'pandoc-lik':37 'pars':52,149 'parser':21 'plugin':5,13,76,155,167 'popular':17 'primari':104 'primarili':86 'provid':72 'releas':68 'render':26,112,137 'respons':88 'seamless':141 'setup':147 'special':12 'specif':31 'stabil':82 'stabl':61 'standard':118 'standards-compli':117 'sub':9,173 'subscript':4,27,57,111,161,172 'support':159 'syntax':33 'tag':29 'term':81 'tild':46 'typic':77 'updat':85 'version':62 'within':92 'without':127 '~2':49 '~o':50","created_at":"2026-04-20T01:54:52.215755+00:00","updated_at":"2026-04-20T01:54:52.215755+00:00","problems":[{"fix":"Ensure `markdown-it` is imported and instantiated correctly: `const MarkdownIt = require('markdown-it'); const md = new MarkdownIt();` or `import MarkdownIt from 'markdown-it'; const md = new MarkdownIt();`.","cause":"The `markdown-it` parser instance (`md`) was not correctly initialized before attempting to register the plugin, or `markdown-it` was imported incorrectly.","error":"TypeError: md.use is not a function"},{"fix":"For CommonJS, use `const markdownitSub = require('markdown-it-sub');`. For ESM, use `import markdownitSub from 'markdown-it-sub';`. In browsers without a module loader, ensure the script is loaded and refer to `window.markdownitSub`.","cause":"The `markdown-it-sub` plugin was not correctly imported or required into the current scope.","error":"ReferenceError: markdownitSub is not defined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/markdown-it/markdown-it-sub","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/markdown-it-sub","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-18","install_tag":null}}