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

@hypertext-md/parser

v0.2.0

Published

Parser for Hypertext Markdown (HTMD) — Markdown with layout block syntax

Readme

@hypertext-md/parser

Parser for Hypertext Markdown (HTMD) — Markdown extended with layout block syntax. You write plain text, the parser turns it into a typed AST of layout blocks — heroes, grids, pricing tables, forms, and 30+ more.

Install

npm install @hypertext-md/parser

Quick start

An .htmd document is Markdown plus ::: keyword blocks:

::: hero center
# Write websites. Don't click them together.
## Markdown with layout syntax.
[Open playground](/playground) [Read the syntax](/syntax)
:::

parse turns it into a typed AST:

import { parse } from '@hypertext-md/parser';

const { frontmatter, blocks, errors } = parse(source);
// blocks[0]
{
  type: 'hero',
  attrs: { align: 'center' },
  heading: "Write websites. Don't click them together.",
  subheading: 'Markdown with layout syntax.',
  body: [],
  ctas: [
    { label: 'Open playground', href: '/playground', variant: 'primary' },
    { label: 'Read the syntax', href: '/syntax', variant: 'secondary' },
  ],
}

The parser is a pure function from string to AST — synchronous, no I/O, no DOM, no dependencies. To turn the AST into HTML, pair it with @hypertext-md/renderer (or write your own renderer against the AST types):

import { parse, parseInline } from '@hypertext-md/parser';
import { defaultRenderer } from '@hypertext-md/renderer';

const { blocks } = parse(source);
const html = blocks
  .map(b => defaultRenderer.renderBlock(b, { parseInline }))
  .join('\n');

Result (formatted for readability):

<section class="htmd-hero center">
  <h1>Write websites. Don't click them together.</h1>
  <h2>Markdown with layout syntax.</h2>
  <div class="ctas">
    <a href="/playground" class="btn-primary">Open playground</a>
    <a href="/syntax" class="btn-secondary">Read the syntax</a>
  </div>
</section>

Full syntax reference and live playground: hypertext-md.com

What's here

Pure TypeScript source, no runtime dependencies. Distributed two ways:

  1. npm package @hypertext-md/parser — for Node tooling, build plugins, the CLI, the VS Code extension, etc.
  2. Browser bundle htmd-parser.browser.js — a dependency-free IIFE bundle, published as a generic package. hypertext-md.com loads this artifact at build time instead of maintaining its own copy of the parser.

This two-way distribution resolves the technical debt described in the main docs (CLAUDE.md in the hypertext-md.com repo, chapter 6.1): there's now only one parser implementation, compiled for two targets.

Development

npm install
npm test                # run the test suite (141 tests)
npm run typecheck
npm run build           # → dist/index.js (npm distribution)
npm run build:browser   # → dist/htmd-parser.browser.js (IIFE)

API

import { parse } from '@hypertext-md/parser';

const { frontmatter, blocks, errors } = parse(htmdSource);
  • frontmatter — key/value pairs from the optional --- header
  • blocks — array of typed block nodes (see src/types.ts for the full AST)
  • errors — recoverable syntax problems; parsing never throws, unknown block keywords become unknown nodes

Each error carries line, message and raw. line is 1-based and counted in the document you passed in, frontmatter included, so it can be shown to a user or handed to an editor without adjustment. It points at the block's ::: header.

Also exported: parseInline (inline markdown → HTML, used by renderers) and the lower-level helpers extractFrontmatter, parseAttrs, parseLinks, parseImage, parseHeading.

Versioning

Tags in the format vX.Y.Z trigger the npm release (publish:npm job). Every push to the default branch also updates the browser bundle in the package registry (latest tag and a SHA-tagged version for reproducibility).