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

@htmdjs/parser

v0.1.0-alpha.5

Published

Parse .htmd source into a typed AST

Readme

@htmdjs/parser

Dependency-free parser for HTMD: Markdown prose and custom-element structure, with diagnostics and explicit partial-source handling.

import { Parser } from '@htmdjs/parser';

const parser = Parser.getInstance();
const partial = parser.parse('Hello <file-pre', { streaming: true });
// partial.pending === true; the incomplete tag is withheld from renderable nodes.
const final = parser.parse('Hello <file-pre');
// The unfinished source remains literal Markdown with an incomplete-tag diagnostic.

ParseResult contains document, diagnostics, and pending. document.source always retains the original input. Streaming mode defers missing-close warnings for open elements and preserves their available children. Known unfinished tag syntax, fences, and inline backtick spans set pending; this is not a detector for every incomplete Markdown construct. Final parsing always clears pending.

ElementBlock.complete is true for self-closing elements and elements whose closing tag was found, and false while the closing tag has not arrived. Renderers use it to defer components whose contracts require complete source.

ParseOptions:

  • streaming: buffer incomplete custom tags and keep open elements open until finalization.
  • rawTextTags: tags whose content is a raw text payload, never parsed as custom elements (default DEFAULT_RAW_TEXT_TAGS: htmd-fragment and code-block). Pass catalog.rawTextTags() from @htmdjs/contracts to match a host catalog.
  • maxDepth: custom-element nesting limit (default 64). Opening tags nested deeper stay literal Markdown with a nesting-too-deep error diagnostic.

The parser keeps Markdown verbatim; it does not interpret or repair it. Provisional rendering of an unfinished Markdown frontier happens in @htmdjs/renderer. Code fences and code spans do not create custom elements. Final rendering must use a Markdown renderer with raw HTML disabled.

Attribute values decode the five named XML-style entities and valid decimal/hex Unicode references exactly once. Unknown/invalid references stay literal. This backfills Bench's round-trip fix; consumers must not decode attributes again. Forbidden-scheme diagnostics inspect decoded values but are not a replacement for component URL policies.

Part of HTMD. Install with npm install @htmdjs/parser@alpha.