LIGHTWEIGHT MARKDOWN PARSER!
A pure JavaScript Markdown library with real-time split-screen editing, virtual DOM diffing, and zero-framework lightweight design
npm i @pardnchiu/nanomd· Documentation
Built-in MDEditor and MDViewer synchronization renders results instantly while writing, with configurable sync scrolling and render delay.
Built entirely on native JavaScript and DOM APIs without React, Vue, or any framework dependency, importable via CDN or npm with minimal bundle size.
MDEditor, MDViewer, and MDParser operate independently — use Parser alone for Markdown-to-HTML conversion or combine editor and viewer for full editing experience.
Built-in vDOM diffing compares old and new node trees and patches only the changed parts, minimizing unnecessary DOM operations.
Covers headings, bold, italic, strikethrough, highlight, superscript, subscript, code blocks, tables, lists, blockquotes, checkboxes, and horizontal rules.
Write Mermaid syntax directly in Markdown and get auto-rendered flowcharts, sequence diagrams, and other visualizations in the preview.
Supports #hashtag syntax that auto-converts to clickable links with customizable path prefix and open target.
Provides syntax highlighting for over 20 programming languages including JavaScript, Python, Go, and Rust.
Export editor content as Markdown or HTML files, and import external Markdown files directly into the editor.
Supports Light, Dark, and Auto theme modes — Auto mode detects system preference and applies the corresponding theme.
Built-in undo/redo history stack, keyboard shortcuts, auto-indentation, and pinnable toolbar for enhanced editing workflow.
graph LR
A[MDEditor] -->|raw text| B[MDParser]
B -->|HTML| C[MDViewer]
A -->|sync scroll| C
NanoMD/
├── dist/
│ ├── NanoMD.js # Minified build
│ ├── NanoMD.esm.js # ESM module
│ ├── NanoMD.debug.js # Debug build
│ └── NanoMD.css # Stylesheet
├── src/
│ ├── data.js # Constants, regex, and config
│ ├── function/ # Parsing utilities (30+ modules)
│ └── model/
│ ├── editor.js # MDEditor core
│ ├── viewer.js # MDViewer core
│ ├── parser.js # MDParser core
│ ├── vDOM.js # Virtual DOM diff algorithm
│ ├── editorHistory.js # Undo / Redo management
│ ├── editorKeydown.js # Shortcut handling
│ ├── editorCaret.js # Cursor positioning
│ ├── editorSelection.js # Selection operations
│ ├── editorPanel.js # Toolbar
│ └── editorTab.js # Tab behavior
├── static/ # Website assets
├── page/ # Website pages
├── package.json
└── LICENSE
This project is licensed under the MIT LICENSE.
©️ 2024 邱敬幃 Pardn Chiu