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

@plim/html

v0.4.0

Published

Plim HTML: headless, SSR-safe serialization of Plim documents to HTML, with built-in renderers for every block and mark plus an overridable registry for custom content.

Readme

@plim/html

@plim/html is a headless, SSR-safe serializer for turning a Plim document model into an HTML string. It uses no DOM APIs, so it can run in Node, edge runtimes, server previews, SEO rendering, and email pipelines. It is the read-only, server-side counterpart to @plim/editor, and is optional.

Install

pnpm add @plim/html @plim/core

Usage

import { serializeToHTML } from '@plim/html';

const html = serializeToHTML(doc);

serializeToHTML accepts a DocumentNode, EditorState, Snapshot, or BlockNode[]. By default it returns an HTML fragment. Pass { document: true } to wrap the result in a minimal <!doctype html><html><body>… document.

Custom renderers

Built-in block and mark renderers are exposed and can be overridden or extended. Custom renderers receive a recursive context with escaping helpers and the resolved registries.

import { serializeToHTML, type BlockRenderer } from '@plim/html';

const callout: BlockRenderer = (node, ctx) =>
`<aside${ctx.attr('class', ctx.classFor('callout'))}>${ctx.renderInline(node.text)}${ctx.renderBlocks(node.children ?? [])}</aside>`;

const html = serializeToHTML(doc, {
classPrefix: 'my-editor-',
blocks: {
callout,
},
});

Unknown blocks never throw; they render as a neutral <div data-block-type="…">…</div> unless onUnknownBlock is supplied. Unknown marks pass their inner HTML through unchanged.

Security

All text and attribute values are escaped by default, including links, image attributes, and custom helpers via ctx.escape() and ctx.attr(). The only exception is the raw_html block, which is emitted verbatim from attrs.html, attrs.content, attrs.raw, or its text content. Only serialize trusted raw_html content or sanitize it before it enters the document, otherwise it can execute XSS.

Tables

Core only defines the table block name. This package supports attrs.rows as arrays/cell objects when present, otherwise it treats table children as rows and each row's children as cells as a best-effort structural representation.

API

  • serializeToHTML(input, options?)input is a DocumentNode, EditorState, Snapshot, or BlockNode[]; options includes document, classPrefix, blocks, marks, and onUnknownBlock.
  • defaultBlockRenderers / defaultMarkRenderers — the built-in renderer maps, exported so you can extend rather than replace them.
  • toDocumentNode(input) — normalize any accepted input to a DocumentNode.
  • escape(value) / attr(name, value) — the escaping helpers also available on the render context as ctx.escape / ctx.attr.
  • Types: BlockRenderer, MarkRenderer, RenderContext, HTMLInput, HTMLSerializerOptions.

Where to go next

License

See the LICENSE file in this package.