npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xubpa/ghmd

v0.2.0

Published

GitHub-style Markdown preview: standalone server + VS Code extension

Readme

ghmd — GitHub Markdown Preview

Pixel-perfect GitHub rendering, locally. Works as a standalone server (browser) and a VS Code extension.

Version Node License Size


Why GHMD?

| | GHMD | Built-in Preview | MPE | |---|:---:|:---:|:---:| | GitHub-accurate rendering | Yes | No | Approximate | | Alerts, footnotes, math, mermaid | All | None | All | | Install size | ~420 KB | Built-in | ~50 MB | | Config required | Zero | Zero | Extensive | | Standalone server | Yes | No | No |


Features

| Feature | Syntax | |---------|--------| | GitHub Alerts | > [!NOTE], > [!TIP], > [!IMPORTANT], > [!WARNING], > [!CAUTION] | | Mermaid diagrams | ```mermaid (flowchart, sequence, gantt, class, state, ER, pie, git) | | LaTeX math | $...$ inline, $$...$$ block | | Code highlighting | ```lang via marked-highlight + highlight.js | | Diff highlighting | ```diff with +/- lines | | Collapsible sections | <details> / <summary> | | Footnotes | [^label] | | YAML front matter | --- metadata rendered as table | | Emoji shortcodes | :sparkles: → ✨ (full GitHub set via gemoji) | | Auto-linked URLs | Bare URLs become clickable links | | Task lists | - [x] / - [ ] | | Keyboard keys | <kbd>Cmd</kbd> | | Sub/superscript | <sub> / <sup> | | Theme-aware images | <picture> with prefers-color-scheme | | Light/dark toggle | Toolbar button, persisted | | Table of contents | Collapsible TOC panel | | Live reload | Auto-updates on file change |


Install

git clone [email protected]:Ubpa/ghmd.git
cd ghmd
npm install

Usage

Standalone Server

node serve.mjs README.md              # http://localhost:6419
node serve.mjs docs/guide.md 8080     # custom port

Auto-reloads in browser on file change. KaTeX and Mermaid load from CDN.

Root mode (multi-file)

Serve any markdown file under a directory and switch via ?file=:

node serve.mjs --root ./docs --port 6419
# http://127.0.0.1:6419/                  → renders ./docs/README.md (if any)
# http://127.0.0.1:6419/?file=guide.md    → renders ./docs/guide.md
# http://127.0.0.1:6419/?file=sub/x.md    → renders ./docs/sub/x.md

--port 0 lets the OS pick a free port. ghmd prints LISTENING http://127.0.0.1:<port> on the first stdout line so a parent process spawning ghmd can pick up the chosen port.

Path is constrained to <root>.. escapes return 400, non-markdown files return 400, missing files return 404.

node serve.mjs --init                  # one-time: downloads katex + mermaid
node serve.mjs README.md              # now fully offline

VS Code Extension

Install

npm run package                        # build + create .vsix
code --install-extension ghmd-*.vsix --extensions-dir ~/.vscode/extensions

[!WARNING] The code CLI may install to a different extensions directory than your editor loads from (e.g. ~/.cursor/extensions/ vs ~/.vscode/extensions/). Use --extensions-dir to target the correct path. After installing, run Cmd+Shift+P → Developer: Reload Window.

Keybindings

| Shortcut | Action | |----------|--------| | Cmd+K V | Open preview to the side | | Shift+Cmd+V | Open preview (same tab) |

[!TIP] The preview automatically follows your active markdown editor — no need to reopen when switching files.

The extension replaces the built-in markdown preview button with the GitHub icon. Theme toggle and TOC panel are in the top-right corner.

Scroll Sync

Bidirectional scroll sync between editor and preview:

  • Editor → Preview: scrolling the editor smoothly scrolls the preview to the matching position
  • Preview → Editor: scrolling the preview jumps the editor to the corresponding source line

How It Works

flowchart LR
    MD["Markdown file"] --> P[marked + plugins]
    P --> H["highlight.js"]
    H --> HTML["GitHub-styled HTML"]
    HTML --> K["KaTeX (math)"]
    HTML --> M["Mermaid (diagrams)"]
    K --> R["Rendered preview"]
    M --> R

Both entry points share the same pipeline:

  1. marked parses GFM with plugins: alerts, footnotes, front matter, emoji, auto-linking, syntax highlighting
  2. marked-highlight + highlight.js handle code syntax highlighting
  3. source-lines wraps all block renderers to inject data-source-line attributes (for scroll sync)
  4. github-markdown-css provides GitHub's exact styling
  5. KaTeX renders math client-side
  6. Mermaid renders diagrams client-side

[!NOTE] Both entry points load KaTeX, Mermaid, highlight.js CSS, and github-markdown-css from CDN. The standalone server also supports offline mode via --init. The VS Code extension ships as a ~420 KB .vsix with no vendored assets.


Development

npm install                            # install dependencies
npm run build                          # bundle extension + server
npm run dev                            # build with sourcemaps (F5 debugging)
npm run typecheck                      # tsc type checking only
npm run package                        # build + create .vsix
npm test                               # build + VS Code e2e tests (headless)
npx tsx test/unit/frontmatter.test.mts # frontmatter unit tests
npx tsx test/unit/svg-slider.test.mts  # SVG slider unit tests
ghmd/
  src/
    extension.ts        VS Code extension (bundled → dist/extension.cjs)
    serve.mts           Standalone server (bundled → dist/serve.mjs)
    frontmatter.ts      YAML front matter extension for marked
    source-lines.ts     Injects data-source-line attrs for scroll sync
    scroll-sync.js      Client-side bidirectional scroll sync
    ui.css              Shared UI styles (read at runtime by both entry points)
    toc.js              Shared TOC logic (read at runtime by both entry points)
  test/
    suite/              VS Code e2e tests (mocha + @vscode/test-electron)
    unit/               Unit tests (run with tsx, no VS Code required)
  dist/                 Build output (gitignored)
npm update                             # update node_modules
npm run build                          # rebuild vendor/ + dist/
npm run package                        # create new .vsix