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

pilcrow-nextjs

v0.1.0

Published

Build-time editorial typesetting for Next.js MDX pipelines — drop caps, sidenote-aware lines, hyphenation. Built on @chenglou/pretext.

Readme

pilcrow-nextjs ¶

A build-time rehype plugin that drops Pilcrow typesetting into a Next.js MDX pipeline.

The hard part, measuring each line at the page's actual font and column width, is done by pretext, @chenglou's text-layout library. pilcrow-nextjs is a thin shim: it reads the rehype HAST tree your MDX file compiles to, hands the rendered HTML to pilcrow-typeset, and splices the typeset output back into the tree before Next.js's MDX bundler turns the result into JavaScript.

What it does

When next build compiles an .mdx page, this plugin intercepts the rehype pass, serialises the post body to HTML, runs typeset(), and replaces every <p> with per-line <span class="pt-line"> spans. Drop caps, hyphenation, and sidenote-aware lines are handled by pilcrow-typeset. The output is static HTML baked into your Next.js build artefacts; nothing runs at request time and no JavaScript is shipped to the reader on its account.

A single Chromium instance is opened on first invocation per build and reused across .mdx files, so you pay the browser-launch cost once.

Build environment requirements

Next.js bundles MDX at compile time. Doing this work at request time inside a serverless or edge runtime is not viable, so pilcrow-nextjs runs at build time only. That means next build (and any next dev compile pass) needs an environment that can install and launch headless Chromium.

Confirmed working on Vercel, Netlify, Cloudflare Pages, GitHub Actions, and GitLab CI. Locked-down build images that block browser sandboxing or omit the Chromium binary will not work.

Node ≥18.17.1. Next.js ≥14 and Playwright ≥1.40 are peer dependencies.

Install

npm install pilcrow-nextjs pilcrow-typeset @next/mdx @mdx-js/loader @mdx-js/react
npx playwright install chromium

next.config.mjs

import createMDX from '@next/mdx';
import pilcrowNext from 'pilcrow-nextjs';

const withMDX = createMDX({
  extension: /\.mdx?$/,
  options: {
    remarkPlugins: [],
    rehypePlugins: [[pilcrowNext, {}]],
  },
});

/** @type {import('next').NextConfig} */
const nextConfig = {
  pageExtensions: ['ts', 'tsx', 'js', 'jsx', 'md', 'mdx'],
};

export default withMDX(nextConfig);

The plugin is the last rehype step you want before the MDX code generator runs, because pretext needs the final rendered HTML structure to measure against.

Options

rehypePlugins: [[pilcrowNext, {
  fontShorthand: '18px ui-serif',
  maxWidth: 720,
  lineHeight: 30,
  dropCap: true,
}]]

| Field | Type | Default | Meaning | |---|---|---|---| | fontShorthand | string | '' | CSS font shorthand. Empty = read computed value from your CSS at typeset time. | | maxWidth | number | 0 | Column width in CSS pixels. Zero = fall back to the page's clientWidth. | | lineHeight | number | 0 | Line height in CSS pixels. Zero = read from computed style. | | dropCap | boolean | true | Drop cap on the lede paragraph. Set false to opt out. |

The empty-string and zero defaults are deliberate. They tell the renderer to read the values from your stylesheet, so your CSS stays the single source of truth for measurement geometry.

MDX with JSX

Pure-Markdown .mdx files typeset normally. If a file contains JSX components or {expression} nodes, those are MDX-AST shapes that cannot survive the HTML round-trip the plugin performs. When the plugin sees one, it logs a warning to stderr naming the file and returns the tree unchanged. Move the JSX out into a layout or surrounding page if you want the body content typeset.

Documentation

Full Pilcrow documentation at pilcrow.page.

Credit

Most of the work behind any line you read on a Pilcrow site happens inside pretext. Cheng Lou wrote it. pilcrow-nextjs is the bit that knits pretext into Next.js's MDX pipeline; the editorial primitives (drop caps, sidenote spans, hyphenation, the orphan guard) live in pilcrow-typeset.

Licence

MIT.


Built on pretext by @chenglou.