NMD — Markdown Preview
A VS Code extension that renders Markdown with syntax highlighting, Mermaid diagrams, and scroll sync. All rendering runs locally — no network calls.
Features
- Live preview — updates on every keystroke (300 ms debounce in panel mode)
- Shiki syntax highlighting — GitHub Dark theme, bundled (no CDN)
- Code block actions — tagged blocks get a language header, copy button,
line numbers, and soft-wrap
- Real, 100% Offline Mermaid Diagrams (Pele) — powered by Pele, Obsidian's lightweight, synchronous, zero-dependency engine (~220KB bundle vs 1.25MB+ Mermaid.js)
- 100% Offline KaTeX Math — inline (
$\rightarrow$, $E = mc^2$), block ($$...$$), and GitLab-style (```math) math with bundled vector fonts and zero network requests
- Logical Line Indicators — small, borderless line numbers along the left margin every 10th logical line (10, 20, 30...), directly matching editor lines and automatically adapting as text wraps
- Scroll sync — editor scroll position mirrors to the preview panel
- Local link navigation — clicking relative links opens the file in VS Code
- Front-matter acronyms — define acronyms in YAML front matter; matching text is wrapped in
<abbr> with tooltip
- Warning blockquotes — blockquote lines starting with
! render with a red left border
- Zoom & scaling —
Ctrl + MouseWheel or trackpad pinch zooms preview content smoothly with cursor anchoring; Ctrl+0 resets, Ctrl+=/Ctrl+- adjusts zoom
Usage
Custom editor (default)
Opening any .md file uses the NMD preview as the default editor. To edit the raw Markdown, right-click the file → Open With… → Text Editor.
Side-by-side panel
| Action |
Shortcut |
| Toggle preview panel |
Ctrl+Shift+M |
| Open file link in preview |
click the link |
The panel tracks the active editor — switching tabs updates the preview automatically.
Front-matter acronyms
---
acronyms:
API: Application Programming Interface
SLA: Service Level Agreement
---
Any occurrence of API or SLA in the document body is wrapped in an <abbr> tag, producing an underlined tooltip on hover. Occurrences inside <code>, <pre>, or <a> are left untouched.
Code blocks
Language-tagged fenced code blocks get a small header with the language name on
the left and a Copy button on the right. Tagged blocks also show line numbers
and soft-wrap long lines. Untagged blocks still get the Copy button, but no
language label or line numbers.
Offline Mermaid Diagrams (Pele)
NMD embeds Pele, Obsidian's lightweight, ultra-fast, zero-dependency Mermaid diagram engine. Diagrams render synchronously and 100% offline with full Mermaid syntax compatibility and a much smaller bundle size (~220KB vs 1.25MB+):
```mermaid
graph TD
A[Start] --> B{Decision}
B -->|Yes| C[Done]
B -->|No| A
```
Supported Diagram Types:
- Flowcharts & Architecture Graphs (
graph, flowchart)
- Sequence Diagrams (
sequenceDiagram)
- Class & State Diagrams (
classDiagram, stateDiagram, stateDiagram-v2)
- Entity Relationship (ER) Schemas (
erDiagram)
- Gantt Charts & User Journeys (
gantt, journey)
- Git Graphs & Mindmaps (
gitGraph, mindmap)
- Pie & Quadrant Charts (
pie, quadrantChart)
Logical Line Indicators
To easily orient yourself between the Markdown source document and the rendered HTML preview, NMD displays small, unobtrusive line indicators in the left margin:
- Every 10th Logical Line: Numbers appear at line 10, 20, 30, 40, etc., directly matching the editor gutter (including YAML front-matter lines).
- Responsive Text Wrapping: Logical lines stay anchored to their rendered text even as paragraphs wrap dynamically with window resizing.
- Empty Line Skipping: If a multiple of 10 falls on an empty line, the indicator appears on the next non-empty line showing its actual line number (e.g.
10, 34, 40), then resumes counting to the next multiple of 10.
- Distraction-Free: Clean, borderless numbers in muted gray at half text size (
7.5px) with pointer-events: none so they never interfere with text selection or interaction.
Offline LaTeX / KaTeX Math
NMD embeds the complete KaTeX engine along with all math vector fonts offline:
Currency expressions like $50 bucks and $100 and inline code snippets like `$x$` remain literal text and are never falsely parsed as math.
Zoom & scaling
The preview supports independent zooming without affecting VS Code's overall UI zoom:
| Action |
Input |
| Zoom in / out |
Ctrl + MouseWheel (or trackpad pinch) |
| Step zoom in |
Ctrl + = / Ctrl + + |
| Step zoom out |
Ctrl + - |
| Reset to 100% |
Ctrl + 0 |
- Cursor anchoring — content under the mouse cursor remains stationary while zooming.
- Visual badge — a floating percentage pill appears in the top-right corner and fades out automatically.
- Session persistence — the zoom factor is remembered across tabs and restored across VS Code restarts.
- Bounds — clamped between 30% and 500%.
Install from VSIX
code --install-extension nmd-1.2.0.vsix
Development
npm install
npm run watch # or: npm run compile
Press F5 in VS Code to launch the Extension Development Host.
Bundled libraries