{"id":16112,"library":"markdown-it-mark","title":"Markdown-It Mark Plugin","description":"The `markdown-it-mark` package is a plugin for the `markdown-it` markdown parser, designed to extend its functionality by adding support for the HTML `<mark>` tag. It enables users to highlight text within their Markdown documents using the `==text==` syntax, which is then rendered as `<mark>text</mark>`. The current stable version is 4.0.0, last published approximately two years ago, indicating a mature and stable project likely in maintenance mode rather than rapid feature development. This plugin is highly focused, providing a straightforward implementation for text highlighting that adheres to similar rules as CommonMark emphasis. Its key differentiator is its seamless integration with the `markdown-it` ecosystem, offering a lightweight solution for a common formatting need without introducing complex parsing behaviors.","status":"maintenance","version":"4.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/markdown-it/markdown-it-mark","tags":["javascript","markdown-it-plugin","markdown-it","markdown","mark"],"install":[{"cmd":"npm install markdown-it-mark","lang":"bash","label":"npm"},{"cmd":"yarn add markdown-it-mark","lang":"bash","label":"yarn"},{"cmd":"pnpm add markdown-it-mark","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"This package is a plugin for `markdown-it` and requires a compatible version of the core parser. Version 3.x and later of `markdown-it-mark` specifically require `markdown-it` version 10.x or higher for proper functionality.","package":"markdown-it","optional":false}],"imports":[{"note":"Since v4, `markdown-it-mark` provides both CommonJS and ESM exports. The default ESM export is the plugin function itself. `markdown-it` also supports ESM imports.","wrong":"import { markdownitMark } from 'markdown-it-mark';","symbol":"markdownitMark","correct":"import markdownit from 'markdown-it';\nimport markdownitMark from 'markdown-it-mark';\n\nconst md = markdownit().use(markdownitMark);"},{"note":"This is the documented CommonJS `require` pattern for both `markdown-it` and the plugin, as shown in the README examples.","wrong":"const { markdownitMark } = require('markdown-it-mark');","symbol":"markdownitMark (CommonJS)","correct":"const markdownit = require('markdown-it');\nconst markdownitMark = require('markdown-it-mark');\n\nconst md = markdownit().use(markdownitMark);"},{"note":"For browser environments where the script is loaded directly without a package manager, the plugin attaches itself globally to `window.markdownitMark`. `markdown-it` itself similarly attaches to `window.markdownit`.","symbol":"window.markdownitMark","correct":"// When loaded directly in a browser via <script> tag:\nconst md = window.markdownit().use(window.markdownitMark);"}],"quickstart":{"code":"import markdownit from 'markdown-it';\nimport markdownitMark from 'markdown-it-mark';\n\n// Initialize markdown-it with the mark plugin\nconst md = markdownit();\nmd.use(markdownitMark);\n\n// Markdown input with mark syntax\nconst markdownInput = 'This is ==marked== text and also ==important== content.';\n\n// Render to HTML\nconst htmlOutput = md.render(markdownInput);\n\nconsole.log(htmlOutput);\n// Expected output: <p>This is <mark>marked</mark> text and also <mark>important</mark> content.</p>","lang":"javascript","description":"This quickstart demonstrates how to initialize `markdown-it` and register `markdown-it-mark` to parse and render `==marked==` syntax into `<mark>` HTML tags."},"warnings":[{"fix":"Upgrade `markdown-it` to at least version 10.0.0: `npm install markdown-it@^10.0.0` (or the latest compatible version).","message":"Version 3.0.0 and subsequent major versions of `markdown-it-mark` (including 4.0.0) introduced a breaking change that requires `markdown-it` version 10.0.0 or higher. Older versions of `markdown-it-mark` may work with older `markdown-it` versions, but for v3.x and v4.x, ensure `markdown-it` is updated.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Ensure that `==` delimiters directly surround the text to be marked, without leading or trailing spaces within the delimiters (e.g., `==marked==`, not `== marked ==`).","message":"The `==text==` syntax for marking text strictly follows the same conditions as CommonMark emphasis rules. This means that the delimiters `==` must be balanced and not contain whitespace immediately inside them to correctly parse. For instance, `== mark ==` will not render as `<mark> mark </mark>`.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure `markdownit` is imported and instantiated correctly (e.g., `const markdownit = require('markdown-it'); const md = markdownit();` or `import markdownit from 'markdown-it'; const md = markdownit();`).","cause":"This error typically occurs if `markdown-it` has not been correctly initialized or imported, or if `md` is not an instance of `MarkdownIt` before calling `.use()`.","error":"TypeError: md.use is not a function"},{"fix":"Run `npm install markdown-it-mark` to install the package. Verify the import/require path matches your module system configuration.","cause":"The `markdown-it-mark` package is not installed or the `require`/`import` path is incorrect.","error":"Error: Cannot find module 'markdown-it-mark'"},{"fix":"Ensure `md.use(markdownitMark)` is called after `markdown-it` initialization. Check that the markdown syntax is `==text==` with no internal spaces, similar to CommonMark emphasis rules.","cause":"The plugin might not be registered with `markdown-it`, or the input Markdown syntax for marking is incorrect (e.g., contains spaces inside `==` delimiters or has unbalanced delimiters).","error":"Text enclosed in '==' is not being rendered as <mark> tags."}],"ecosystem":"npm"}