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

@orkestrel/markdown

v0.0.7

Published

A types-first markdown layer over @orkestrel/html — typed AST, both conversion directions, and sanitized HTML by default.

Downloads

3,591

Readme

@orkestrel/markdown

A types-first markdown layer over @orkestrel/html: parse GitHub-Flavored Markdown into a typed AST, project that AST out to sanitized HTML or to canonical markdown source, and project an HTML AST back in.

  • One AST, several projections. Nodes are plain readonly data keyed by element; parsing, querying, rewriting, folding, streaming, and every conversion are operations over it.
  • Both directions live here. markdownToHTML and htmlToMarkdown are inverse projections across the boundary, because what an HTML subtree means in markdown is markdown's knowledge, not html's.
  • Sanitized by default, with no opt-out. renderHTML takes one argument and composes @orkestrel/html's sanitize floor, so there is no call shape that emits unsafe HTML.
  • Bounded by design. Every parse, traversal, and projection is iterative and depth-capped, so malformed or hostile input degrades to literal text instead of throwing.

Install

npm install @orkestrel/markdown

Requirements

  • Node.js >= 22.12
  • Ships ES and CommonJS builds with its own .d.ts types
  • Two runtime dependencies, @orkestrel/html and @orkestrel/contract

Usage

import { createMarkdown, htmlToMarkdown, renderHTML, renderMarkdown } from '@orkestrel/markdown'
import { parseDocument as parseHTML } from '@orkestrel/html'

const markdown = createMarkdown('# Hi\n\nRead the [guide](./guide.md) for more, *thanks*.')

markdown.document
// { element: 'document', children: [...] } — the typed, render-agnostic AST

renderHTML(markdown.document)
// '<h1>Hi</h1><p>Read the <a href="./guide.md">guide</a> for more, <em>thanks</em>.</p>'

// …and back the other way.
renderMarkdown(htmlToMarkdown(parseHTML('<h1>Release notes</h1><p>Ship <b>fast</b>.</p>')))
// '# Release notes\n\nShip **fast**.'

createMarkdown (or new Markdown) runs a two-phase parse — block phase, then inline phase — and holds the result as a stateful workspace exposing find / filter / map / reduce / fold / stream / iteration over the AST. renderHTML projects that AST onto html's AST, sanitizes it against a floor no option can lower, and serializes it. renderMarkdown writes canonical markdown source instead. htmlToMarkdown folds an HTML AST back down to a MarkdownDocument, re-sanitizing every destination as it goes. Guards (isMarkdownNode, isMarkdownDocument, isBlockNode, isInlineNode) validate an AST that arrives from outside — an RPC payload, a cached document — without ever throwing, and the non-recursive leaf nodes each compile to a @orkestrel/contract bundle of guard, parser, JSON Schema, and seeded generator.

Laws

  • Markdown fixpointparseDocument(renderMarkdown(document)) deep-equals a parser-produced document, and renderMarkdown is idempotent.
  • Projection anchorparseDocument(renderMarkdown(htmlToMarkdown(x))) deep-equals htmlToMarkdown(x): whatever the projection emits, markdown can write it and read it back unchanged.

Both round-trip laws hold within the depth budget — markdown's MAX_DEPTH, plus html's own cap on the inbound trip; beyond it only totality is promised.

  • Sanitized outputrenderHTML refuses javascript:, data:, vbscript:, file:, and protocol-relative destinations, removes unsafe subtrees whole, and strips every handler and styling attribute, whatever the input AST claims.

HTML is richer than markdown, so what survives the inbound trip is the projected AST, not the input bytes: comments and doctypes vanish, an element with no markdown meaning unwraps to its children, and block content inside a table cell flattens to one line.

Guide

For the full surface — the AST shape, the two-phase parse, the sanitization policy, the projection seam, and the contract-backed leaf shapes — see guides/src/markdown.md.

Package

Published as a single typed entry point per the exports field in package.json.

License

MIT © Orkestrel — see LICENSE.