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

@sigx/richtext-html

v0.4.0

Published

HTML for @sigx/richtext — a platform-free parser and a serializer with the CommonMark reference layout, the html DocumentFormat and the text/html clipboard preset

Readme

@sigx/richtext-html

HTML for @sigx/richtext — a platform-free parser (no DOMParser, so it runs on Lynx and in the terminal) that turns the markup reaching a clipboard, a CMS field or an LLM answer into the standard tree, a serializer with the CommonMark reference layout, htmlFormat (the DocumentFormat a view or editor reads and writes with), the HTML slice plugins fill under formats.html, and the text/html clipboard preset. Zero dependencies beyond @sigx/richtext, no node: imports.

| Entry | What | |---|---| | @sigx/richtext-html | htmlFormat, parseHtml, toHtml, the HtmlPluginSlice contract (elements: tag → node rules, serialize: node → HTML rules), mentionHtml, the tokenizer and tree for custom tooling | | @sigx/richtext-html/editor | htmlPreset — copying blocks puts text/html on the clipboard next to the primary format's flavour |

Install

npm install @sigx/richtext @sigx/richtext-html

Peers on @sigx/richtext and on @sigx/reactivity / @sigx/runtime-core at the same minor as your app's sigx.

Taste

Markdown and HTML are the same tree, so converting is parse then serialize:

import { markdownFormat } from '@sigx/richtext-markdown';
import { htmlFormat, parseHtml, toHtml } from '@sigx/richtext-html';

toHtml(markdownFormat.parse('# Hi\n\nSome **markdown**.'));
// '<h1>Hi</h1>\n<p>Some <strong>markdown</strong>.</p>\n'

markdownFormat.serialize(parseHtml('<h1>Hi</h1><p>Some <b>html</b>.</p>'));
// '# Hi\n\nSome **html**.\n'

The parser repairs what browsers repair (an unclosed <p>, a bare <li>, a table without <tbody>), keeps only href / src (through the core's sanitizeUrl) and treats every unknown element as transparent — pasted markup cannot smuggle handlers or styles into the document.

An editor that reads and writes both:

import { RichTextEditor } from '@sigx/richtext/editor/dom';
import { markdownFormat } from '@sigx/richtext-markdown';
import { markdownPreset } from '@sigx/richtext-markdown/editor';
import { htmlFormat } from '@sigx/richtext-html';
import { htmlPreset } from '@sigx/richtext-html/editor';

<RichTextEditor format={markdownFormat} formats={[htmlFormat]} plugins={[markdownPreset, htmlPreset]} model:source={[note, 'md']} />

Pasting from a browser now parses the text/html flavour (specific flavours win over text/plain), and copying a block selection writes text/markdown and text/html side by side.

A plugin's HTML syntax is a slice keyed by tag (reading) and node type (writing):

const mention: HtmlPluginSlice = {
    elements: { span: (el, ctx) => (el.attrs['data-mention'] ? { type: 'mention', id: el.attrs['data-mention'], label: ctx.text().slice(1) } : null) },
    serialize: { mention: (node, ctx) => `<span data-mention="${ctx.attr(node.id)}">@${ctx.escape(node.label)}</span>` },
};

(mentionHtml is exactly that.)

Documentation

Guides, API reference and live examples: https://sigx.dev/richtext/

License

MIT © Andreas Ekdahl