v1 Deprecation
Last updated
v2 ships only the Markdown parser
MDParser; this page lists the v1 APIs that were removed, their replacements, a migration example and the v1 vs v2 benchmark.Keep Using v1
The v1
MDEditor, MDViewer and MDParser class are deprecated and receive no new features. Projects that need the editor pin 1.11.6:- <script src="https://cdn.jsdelivr.net/npm/@pardnchiu/nanomd@1.11.6/dist/NanoMD.js"></script>
- npm i @pardnchiu/nanomd@1.11.6
Pin the exact version;
@latest or an unversioned URL resolves to v2.Removed APIs
| v1 | Removed | v2 replacement |
|---|---|---|
MDEditor | Removed in v2.0.0 | Use <textarea>, CodeMirror, Monaco or another editor and pass its content to MDParser.Parse() |
MDViewer | Removed in v2.0.0 | Set container.innerHTML = MDParser.Parse(text).html() and call MDParser.Refresh(container) |
new MDParser({ standard }).parse(text) | Removed in v2.0.0 | MDParser.Parse(text).html(); the standard option is gone and the full syntax is always on |
PDMarkdownEditor | Removed in v2.0.0 | No public replacement |
ESM exports editor, viewer | Removed in v2.0.0 | import { MDParser } from "@pardnchiu/nanomd" |
sync.editor, sync.delay, sync.scroll | Removed in v2.0.0 | Listen for input and debounce yourself; see the migration example below |
emptyContent | Removed in v2.0.0 | The caller decides what to render for empty content |
hashtag.path, hashtag.target | Removed in v2.0.0 | No public replacement; #tag renders as plain text |
changeMode(), style.mode | Removed in v2.0.0 | Set data-mode on the .nanomd container; see Theming |
style.fill | Removed in v2.0.0 | Set data-fill="1" on the .nanomd container |
download(), openfile(), undo(), redo(), keyboard shortcuts and toolbar | Removed in v2.0.0 | Removed with MDEditor; no public replacement |
Files and Styles
| v1 | v2 |
|---|---|
dist/NanoMD.js | dist/parser.js (global MDParser) |
dist/NanoMD.esm.js | dist/parser.esm.js |
dist/NanoMD.css, dist/NanoMD-output.css | dist/parser.css, loaded automatically by parser.js from the same directory |
Container class .pd-md-viewer | .nanomd |
| Material Symbols, Mermaid and code-prettify injected on load | Loaded on demand with MDParser.Init({ enable }); see Dependencies and Refresh |
Behavior Changes
| Item | v1.11.6 | v2 |
|---|---|---|
$ in text | Rendered as @dollar@ | Rendered as is; a $...$ pair is inline math |
| YouTube/Vimeo previews | Not produced without hashtag.path | Embedded players are always added |
| Raw HTML | Not sanitized | Dangerous tags, event attributes and javascript: URLs are removed |
| Invalid Mermaid syntax | Shows Mermaid's error graphic | Falls back to a plain code block |
| Runtime | Requires a browser DOM | Parse() and html() run in Node.js and Workers |
v1 vs v2
The same sample document, repeated to each size, rendered to HTML in headless Chrome; runs over 15 seconds are recorded as timeouts, and their ratios use 15 seconds as a lower bound.
| Size | v1.11.6 MDParser().parse() | v2 Parse().html() | Speedup |
|---|---|---|---|
| 4.4 KB | 2.6 ms | 0.4 ms | 7× |
| 44.3 KB | 29.6 ms | 1.8 ms | 16× |
| 443.4 KB | 1,790 ms | 17.7 ms | 101× |
| 1.08 MB | 11,037 ms | 47.4 ms | 233× |
| 2.16 MB | Timeout | 82.3 ms | 182× or more |
| 4.33 MB | Timeout | 156.4 ms | 96× or more |
Migration Example
The v1 editor plus viewer becomes any editor plus a debounced render in v2:
- <textarea id="editor" rows="4" style="width:100%"># Hello
- Edit me, the preview updates after you stop typing.</textarea>
- <div id="viewer" class="nanomd"></div>
- <script>
- const editor = document.getElementById("editor");
- const viewer = document.getElementById("viewer");
- let timer;
- function render() {
- viewer.innerHTML = MDParser.Parse(editor.value).html();
- MDParser.Refresh(viewer).catch((err) => console.error(err.message));
- }
- editor.addEventListener("input", () => {
- clearTimeout(timer);
- timer = setTimeout(render, 300);
- });
- render();
- console.log(viewer.querySelector(".md-h1").textContent);
- </script>