neuron-explorer
Steering-first neuron explorer for Qwen3.5-4B: push every MLP neuron, keep every rollout, browse the results
Semantic markdown in, publication-grade pages out — rendered to HTML, canvas, and print-ready PDF.
Translation pending
Developer toolsTypeScript · MDXGitHub @drnachioOnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
A programmable typesetter for the web
Taken from the repository README
Loading the full README. The saved excerpt is shown below.
A programmable typesetter for the web.
Postext is a layout engine that bridges the centuries-old craft of print typesetting and the modern web. It takes semantic content — enriched markdown with referenced resources — and applies professional editorial layout rules to produce publication-grade output for both HTML and PDF.
Built on top of @chenglou/pretext for DOM-free text measurement.
1. Input. Enriched markdown with referenced resources: images, tables, figures, footnotes, pull quotes. The content is semantic, not visual — it describes what to present, not how.Read the full README ↗A programmable typesetter for the web.
🌐 Website: postext.dev · 📖 Documentation: postext.dev/en/docs
Postext is a layout engine that bridges the centuries-old craft of print typesetting and the modern web. It takes semantic content — enriched markdown with referenced resources — and applies professional editorial layout rules to produce publication-grade output for HTML, PDF and EPUB.
Built on top of @chenglou/pretext for DOM-free text measurement.
Enriched Markdown Postext engine Output
───────────────── ───────────────────────── ─────────────
┌────────────────────────┐
# Heading │ │ HTML + CSS
Paragraph text... │ 1. Parse & structure │ ┌─► (web rendering)
More text with a ───► │ 2. Measure (pretext) │ ───┤
:ref{id="fig"} and │ 3. Apply layout rules │ └─► PDF
a $formula$. │ 4. Compute geometry │ (print rendering)
│ │
└────────────────────────┘
▲
Configuration files
(columns, rules, spacing)
Input. Enriched markdown with referenced resources: images, tables, figures, formulas, pull quotes. The content is semantic, not visual — it describes what to present, not how.
Engine. postext parses the content structure, calls pretext for pixel-perfect text measurement without touching the DOM, then runs the layout algorithm: column balancing, resource placement, typographic quality rules, reference systems. All driven by configuration files.
Output. Format-agnostic layout geometry — precise coordinates and dimensions for every element. Renderers translate this geometry to the target format: canvas for page images, HTML/CSS for the web, PDF for print, EPUB 3 for e-book readers, and a 3D book in the browser (Folio).
A professional typesetter — the person who lays out a magazine, a newspaper, or a book — applies dozens of rules that have been refined over centuries:
CSS gives you almost none of this.
column-count exists but is fragile — there is no control over resource placement within columns, no overflow awareness, and no cross-column orphan/widow prevention. There is no native concept of "flow text around an arbitrarily positioned obstacle." Multi-column editorial layouts on the web remain essentially hand-crafted, usually as static designs that break on different screen sizes.
The web has had responsive layout (flexbox, grid) for over a decade. What it has never had is responsive editorial layout — the kind where content reflows intelligently through columns, around images, past footnotes, obeying the rules that make text pleasant to read.
This problem is not new. The Content First project, started around 2014, was an early attempt to bring editorial layout quality to the web. I built column-based layouts, experimented with text flow algorithms, and ran into the same wall repeatedly: you cannot make good layout decisions without knowing exactly how much space text will occupy.
DOM-based measurement is expensive. Every time you ask the browser "how tall is this paragraph at this width?", you trigger a layout reflow. Do this hundreds of times for a complex layout and the page becomes unusable. I needed a way to measure text that was fast enough to run speculatively — trying different layouts, different column widths, different break points — without blocking the main thread.
In 2025, Cheng Lou released pretext: a DOM-free text measurement library that is 300-600x faster than DOM measurement and pixel-perfect across Chrome, Safari, and Firefox. It uses canvas font metrics and pure arithmetic to compute text height and line breaks without ever touching the DOM.
With pretext, the core bottleneck disappears. You can measure thousands of text blocks in milliseconds. You can try ten different column configurations and pick the best one. You can run the full layout algorithm on every resize.
postext is what happens next.
The naming is intentional.
pretext is what happens before text is placed: measuring how much space it will need. DOM-free, canvas-based, operating on pure numbers.
postext is what happens after measurement: the editorial decisions. Given exact dimensions for every text block at any width, the engine decides where each element goes — which column, at what position, flowing around which resources, obeying which typographic rules.
import { prepare, layout } from '@chenglou/pretext';
import { buildDocument } from 'postext';
// pretext: measure (the "pre" work)
const prepared = prepare(paragraphText, '16px/1.5 Inter');
const { height } = layout(prepared, columnWidth, 24);
// => "This paragraph is 144px tall at this column width."
// postext: decide (the "post" work)
const doc = buildDocument(content, config);
// => "Put this paragraph in column 2, starting at y=320.
// Move the image to the top of column 3.
// Float the table to the top of page 3.
// Break here to avoid a widow."
pretext gives you the measurements. postext gives you the layout.
pretext was created by Cheng Lou. postext builds on top of it.
Everything below ships today in postext and its companion packages (postext-pdf, postext-epub, postext-scorm, postext-folio, postext-citeproc) and in the postext command line. A fuller list, with a link to the page that explains each part, is on the wiki's Features page.
layoutType: 'single' | 'double' | 'oneAndHalf') with configurable gutter width, an optional column rule, mirrored margins, a page-wide baseline grid, and crop marks with bleed for print production.sideColumnRole: 'floats'), placed at the outer edge of every page — the marginal column of a textbook — with side captions set level with their figure.:::columns switches the column count mid-page, :::pagebreak forces a break with parity control, :::space adds explicit vertical space, and :::paper changes the paper stock for a run of pages.page.binding), with the PDF asking viewers for right-to-left spreads, and vertical writing (layout.writingMode: 'vertical-rl') for Chinese and Japanese books.'odd', 'even', 'always-odd', …) for chapter openings.:ref{id="…"} references — the first reference floats the resource into the first free top or bottom band after it, spanning the column, the page, or the side channel.::resource{id="…"} embeds a resource inline.Figure and Table built-ins (localized per document language) plus custom resource types, with configurable reference styles and caption prefixes.placement.rotate), cell fills, cell images (bitmap or SVG, aligned within the cell), in-cell lists, and inline colour swatches for legends.diagramStyle.singleInk recolors SVG diagrams to luminance-mapped tints of a single ink, so diagrams survive single-spot-colour printing.:::callout boxes with named calloutStyles: fill, frame, radius, title, icon marker column, and their own paragraph typography — sidebars, key concepts, activities, pull quotes.placement), sit in the side channel, and split across columns and pages when they cannot be kept together, with a continuation that drops the title and icon.paragraphStyles applied with :::paragraphs{style="…"} for bibliographies, glossaries, notes and hanging-indent entries; tables and figures carry their own notes and source lines.:::verse blocks for poetry, including Arabic verse set as two hemistichs.:chip[text]{style="…"}: boxed words (word banks, keys, tags) that wrap as one unit, painted as real text in every backend.:::exercise blocks hold the questions and their answers in the Markdown, in twelve kinds: choice, true or false, gaps and word banks, matching, sorting, ordering, scrambles, words to mark, open questions with ruled writing areas, word searches, crosswords, and operations in columns (long division set as each country's schools set it).exerciseStyles decide how they print: the number badge, option labels, blanks, writing areas and activity icons. The solutions go after the exercise, upside down, at the end of the chapter or of the book, or nowhere, and the same text gives a teacher's edition with every answer filled in.exercises.digital: checks per attempt, resets, when the solution shows, the pass mark) hold in the HTML, the EPUB and a SCORM package. See Exercises.pageTemplates): named frames, groups that share their space, a decoration and spreads, defined once in the configuration.::::page{template="…"} fence sends each piece of content to a frame by name; positions and sizes never appear in the text, so a page is edited and translated as Markdown. A longer translation grows its box and pushes the boxes under it.:::module blocks stack bands of frames down the page, side by side or in rows, nested to any depth. Named frame looks (frameLooks) change a card's colours without a new style, and decoration can be drawn only on pages whose fence asks for it (when / unless).moveTextToMarkdown).:::page cuts a page into panels with a split expression (slanted gutters, bleeds, spreads); each panel takes a picture without lettering and its lines of script.:::strip) for newspapers, right-to-left manga and Arabic editions, and Kindle Panel View in the fixed-layout EPUB.[^id]) set at the foot of the column that cites them, or gathered at the end of the chapter; numbered per chapter, through the book, per page or per column, in decimal, roman or circled numbers (①).{#id}), clickable in the PDF.[@garcia2020, p. 33]) formatted in a CSL style (APA, Chicago, MLA, IEEE, Vancouver, ISO 690, GB/T 7714, OSCOLA, …) with a generated bibliography, from BibTeX, CSL-JSON or CSL-YAML. With a note style each citation becomes a footnote. The styles are applied by postext-citeproc.:index[…] marks and printed with :::index: sub-entries, sort keys, principal pages in bold and several indexes per book. The page numbers are found after layout, so they follow the text.locale) drives hyphenation, built-in strings, numerals, text direction and the language tagged in the PDF.configVersion 21).continuation: page numbers, parity, heading and figure counters and open parts carry across chapters, or the whole book is built as one document.:::part divider pages with their own design, and part palettes that recolour the design and flow of every chapter in the part.headingStyles that govern a whole section — running heads, page geometry, body typography, palette — so front matter can live beside decimal-numbered chapters in one configuration.:::toc prints a table of contents fed by the book's outline, with leaders, numbers and page labels.tableStyle / tableStyles — table typography independent of body text, named variants picked with table.styleId, and a rounded outer frame.captionStyle, chipStyles, calloutStyles, paragraphStyles, headingStyles — every style is a named, reusable object.figureStyle sets the figures of each text style: old-style for running prose, lining for headings, tabular for table columns, proportional where they read best. The engine applies the font's OpenType features in the canvas, HTML, PDF, EPUB and command-line outputs; a face without them keeps its own figures.$…$) and display ($$…$$), rendered to crisp SVG via MathJax in every backend, loaded on demand (await initMathEngine()). MathJax ships pre-bundled, so it loads the same from a bundler, Node or a CDN.```abc, ```musicxml, ```mei or ```humdrum fence, and engraved by Verovio at the width of its column. A long score is cut into systems that run on over columns and pages like lines of text, and scoreStyle.minSystemsAtBreak never leaves a system alone at a break.score resources, numbered, captioned, floated and referenced like figures (Example 3.2), from inline notation or a MusicXML file exported from Dorico, Sibelius, Finale or MuseScore.scoreStyle and named scoreStyles set the staff size, the music font (Bravura, Leland, Petaluma, Leipzig, Gootville), the lyrics font, spacing, bar numbers and ink.Figure with its alt text), inline SVG in a reflowable EPUB, and their notation fence in Word. The engraver loads only for books that have music. See Music notation.:::numbering, with PDF page labels that match the printed folios.renderPage, renderPageToCanvas).renderToHtmlIndexed returns a per-block index so viewers can patch only the DOM nodes that changed between builds.postext-pdf). Print-ready output with document outlines, clickable cross-reference links, embedded custom fonts (woff2/woff/ttf/otf) with GPOS kerning, HarfBuzz shaping for Arabic, page labels, vector SVG figures (with optional PDF print masters), RGB, CMYK, or grayscale color spaces, and tagged, accessible PDF/UA-1 output validated with veraPDF. postext-pdf/worker writes long books off the main thread.postext-epub). The whole book as an EPUB 3.3 file, written in the browser or in Node: a fixed layout (pre-paginated) that keeps every printed page with real, selectable text, or a reflowable book in semantic XHTML (paragraphs rebuilt from the lines, notes, figures and tables in reading order, print page markers) styled from the same configuration. Fonts embedded, with navigation, print page numbers, right-to-left books and accessibility metadata; validated with W3C EPUBCheck.postext-scorm). A book, or the chapters and sections picked from it, as a SCORM 1.2 or SCORM 2004 package for a learning management system (Moodle, Canvas, Blackboard, …): fixed pages or reflowable text from the EPUB writer, a small player per SCO, and exercises that send their score, completion and pass or fail to the LMS (renderToScorm).print.standard) with an ICC output profile (FOGRA, GRACoL, SWOP and IFRA profiles are bundled, or your own), every colour and RGB picture separated through it, black overprint and rich black, an ink limit, and a preflight that reports low-resolution pictures, thin rules, small text in several inks and text near the trim before the file is written. The Sandbox shows a print preview of the separated pages.postext/word). A .docx is read into chapters of Markdown, with its styles mapped to Postext styles and a quality report (readDocx, analyzeDocx, wordToPostext), and a book is written back as .docx with an embedded template (postextToDocx). The Sandbox and the command line both import and export Word.scripts/config-coverage.mjs --check compares the configuration schema with the panel, the docs and the agent skill..postext bundles that carry their pagination, so an imported book opens already paginated..postext files are created and opened from code with the postext package (createBundle, openBundle, buildBundle), so a book moves between the Sandbox, the agent skill and your own program..html download and, where it applies, the PDF; a write-up explains the method step by step, with excerpts of the real code, and the pitfalls. The same content is available as Markdown for agents (/en/cookbook/<slug>.md, and in llms.txt).cookbook/, one folder each (metadata, bilingual write-ups, the pen and its sample text); pnpm cookbook new | dev | lint | capture scaffolds, previews, checks and captures them against the released engine, and pnpm cookbook sandbox and pnpm cookbook bench check the captured books in the Sandbox's own layout and the composed pages under longer text.<page>.md, llms.txt) and WebMCP tools for an agent in the browser: on every page to search, read and open pages, and in the Sandbox to edit the book, change any setting, do anything the Settings panel does (rename or remove a style with everything that names it, apply a language's defaults, upload an ICC profile, save a laid page as a template), get any laid-out page as a JPEG and change again.postext-port teaches a coding agent (Claude Code, Codex, Cursor, Gemini CLI, Copilot, …) to turn an existing publication — a PDF, Word, PowerPoint, EPUB, HTML, InDesign (IDML), LaTeX or scanned source — into a Postext project that follows the original layout: measured config manifest, curated chapters, resources and fonts. Music textbooks, methods and songbooks bring their examples as MusicXML scores.npx skills add drnachio/postext --skill postext-port, or in Claude Code with /plugin marketplace add drnachio/postext + /plugin install postext@postext. See the Skill docs.postext is one self-contained executable per system (macOS arm64 and x64, Linux x64, arm64 and musl, Windows x64): no installation, no runtime, no libraries. The engine, the PDF, EPUB, HTML and Word writers, the page painter (Skia), the default fonts and the ICC print profiles are inside. Every release attaches them to its GitHub Release; readme.txt lists them, and npx postext-cli fetches the right one..postext bundle, an unpacked book folder or loose Markdown files, and writes a PDF (PDF/X and ICC profiles included), HTML, EPUB, one page or every page as PNG, JPEG or WebP, and Word; it also packs and unpacks bundles, imports .docx, describes a book and checks it. postext build --watch keeps the engine warm and rebuilds on every save.--json prints one report (outputs, pages, warnings with file and line, timings), exit codes are stable, -o - writes to stdout, and fonts a book does not carry are fetched once from Google Fonts and cached (--offline never fetches). Run postext with no arguments for the help.postext/
├── apps/
│ └── web/ # Next.js site: landing, docs, sandbox, cookbook
├── packages/
│ ├── postext/ # Core layout engine library
│ ├── postext-pdf/ # PDF rendering backend
│ ├── postext-folio/ # 3D book viewer (three.js)
│ ├── postext-epub/ # EPUB 3 writer (fixed layout and reflowable)
│ ├── postext-scorm/ # SCORM 1.2 / 2004 packages for learning platforms
│ ├── postext-citeproc/ # CSL citations and bibliographies (citeproc-js)
│ ├── postext-cli/ # Command line: self-contained executables (Bun)
│ ├── postext-sandbox/ # Interactive sandbox UI (controls + viewports)
│ └── typescript-config/ # Shared TypeScript configurations
├── docs/ # MDX documentation, <topic>-<locale>.mdx in ten locales
├── cookbook/ # Cookbook recipes (one folder each), registries and pen kit
├── plugins/postext/ # Agent skill `postext-port` (Claude Code plugin + skills.sh)
├── rust/ # Knuth-Plass line breaker in Rust, compiled to WebAssembly
├── .claude-plugin/ # Claude Code plugin marketplace manifest
├── turbo.json # Turborepo task pipeline
├── pnpm-workspace.yaml # pnpm workspace definition
└── package.json # Root scripts (delegate to turbo)
| Package | Purpose |
|---|---|
packages/postext | The core library. Semantic content in, layout geometry out. Zero DOM dependencies. Published to npm as postext. |
packages/postext-pdf | The PDF backend: renders the layout geometry to print-ready, tagged PDF (outlines, links, font embedding, color spaces). Published to npm as postext-pdf. |
packages/postext-folio | The 3D book viewer: a laid-out document (or any page images) as spreads whose leaves turn in three.js. Published to npm as postext-folio. |
packages/postext-epub | The EPUB 3 writer: a laid-out book as a fixed-layout or reflowable EPUB, plus readEpub for viewers. Published to npm as postext-epub. |
packages/postext-scorm | The SCORM writer: a book, or the chapters and sections picked from it, as a SCORM 1.2 or 2004 package whose exercises report to the LMS (renderToScorm). Published to npm as postext-scorm. |
packages/postext-citeproc | The citation engine: formats Pandoc-syntax citations with citeproc-js and builds the bibliography, with 20 bundled CSL styles and 14 CSL locales. Published to npm as postext-citeproc. |
packages/postext-cli | The command line: postext pdf, html, epub, image(s), docx, import-docx, pack, unpack, info, check and build --watch, compiled with Bun into a self-contained executable for each system (pnpm --filter postext-cli build:bin writes them to bin/). Released as GitHub Release assets and on npm as postext-cli. |
packages/postext-sandbox | The interactive sandbox UI — configuration controls and live Canvas/PDF/Folio/HTML/EPUB viewports and the SCORM export — embedded by the web app. |
apps/web | Next.js 16 + Tailwind CSS 4 application: the documentation site, landing page, hosted sandbox and cookbook at postext.dev, in ten languages. |
Documentation lives in the top-level docs/ folder as one MDX file per topic and locale (<topic>-<locale>.mdx, in en, es, ca, fr, de, it, pt, zh, ja and ar), rendered by apps/web. The doc pages of the GitHub wiki are generated from the English files (pnpm wiki in apps/web).
Tech stack: pnpm workspaces, Turborepo 2, TypeScript 6, ESM-only, Node.js 20+, Next.js 16, Tailwind CSS 4, Bun for the command line, Rust for the WebAssembly line breaker.
git clone https://github.com/drnachio/postext.git
cd postext
pnpm install
# Start all packages in dev mode (library watch + Next.js dev server)
pnpm dev
# Build all packages
pnpm build
# Lint all packages
pnpm lint
# Type-check all packages
pnpm check-types
# Run every package's tests (`pnpm test:changed` for only what you touched)
pnpm test
Turborepo handles the dependency graph: packages/postext builds first, then apps/web picks up the changes. In dev mode, the library recompiles on save and the Next.js app hot-reloads.
npm install postext
# or
pnpm add postext
buildDocument takes content plus a configuration object and returns the laid-out document — plain layout geometry, not framework components — which any backend can then render. The quickest path is the HTML string renderer:
import { buildDocument, renderToHtml } from 'postext';
const doc = buildDocument(
{ markdown: '# Hello\n\nThis is postext.' },
{
page: { sizePreset: '17x24' },
layout: { layoutType: 'double', gutterWidth: { value: 0.75, unit: 'cm' } },
bodyText: { fontFamily: 'EB Garamond', fontSize: { value: 8, unit: 'pt' } },
// ...see docs/configuration for the full reference
},
);
// Render to an HTML string (in-browser viewer)
const html = renderToHtml(doc);
// …or rasterize to canvas — see renderPage / renderPageToCanvas.
To leaf through the result as a book in 3D, hand the same document to postext-folio (npm install postext-folio three):
import { createFolioFromDocument } from 'postext-folio';
createFolioFromDocument(document.getElementById('book')!, doc);
To publish it as an e-book, hand the book's chapters to postext-epub (npm install postext-epub):
import { renderToEpub } from 'postext-epub';
const epub = await renderToEpub([doc], {
layout: 'reflowable', // or 'fixed': every printed page as it is
metadata: { title: 'Hello', language: 'en' },
});
Documents that cite ([@key]) need the citation engine from postext-citeproc (npm install postext-citeproc). Register it once before laying out:
import 'postext-citeproc/register';
For interactive integrations — live previews, editors, anything that rebuilds
the document on every keystroke or resize — run the pipeline off the main
thread via the dedicated worker entry point. This keeps the UI responsive,
gives you last-wins cancellation via AbortSignal, and ships fonts into the
worker as transferable ArrayBuffers so measurement stays pixel-identical to
the main-thread build:
import { createLayoutWorker } from 'postext/worker';
const layout = createLayoutWorker();
// Register fonts once per family (woff2/ttf ArrayBuffers are transferred).
await layout.registerFonts(fontPayloads);
const controller = new AbortController();
const vdt = await layout.build(content, config, { signal: controller.signal });
// Call controller.abort() to supersede an in-flight build — the worker stops
// the current pipeline and the pending promise rejects with AbortError.
layout.dispose();
The full async integration pattern (font shipping, cancellation, measurement cache reuse) is documented under Running layout in a Web Worker. For an end-to-end HTML-viewer integration (multi-column, resize-aware, Shadow DOM), see Integrating the HTML viewer.
Every milestone of the original roadmap is closed. Postext now typesets full books — textbooks, magazines, literary editions and catalogues — end to end, from enriched markdown to accessible, print-ready PDF, EPUB 3, SCORM packages and a 3D book. Work continues in programmes tracked as GitHub issues; the wiki's Roadmap page follows them.
@chenglou/pretext for text measurementapps/webbuildDocument with last-wins cancellation).postext book bundles and bilingual showcase presetspostext-citeproc), a back-of-book index (#165)What comes next is driven by the community: open an issue that describes the publication you are trying to set and where Postext falls short.
Postext is a community-driven open-source project. An active community of contributors is growing around it, and new collaborators are always welcome. The goal is to build a shared standard that any editorial development team worldwide can adopt — a common foundation for professional web typography.
If you want to contribute code, please open an issue first to discuss the approach. This helps avoid duplicate work and ensures alignment with the project direction. Follow existing code style and TypeScript strict mode.
The project especially welcomes people with experience in:
For the full community vision and all the ways to get involved, see the Contributing guide.
pretext by Cheng Lou. The foundational text measurement library that makes postext possible. Without DOM-free, pixel-perfect text measurement at sub-millisecond speed, none of this would be practical.
Content First (~2014). The original exploration into high-quality editorial layout on the web. A decade of running into walls, learning what doesn't work, and accumulating the conviction that this problem is worth solving properly.
postext stands on centuries of typographic tradition. The rules it implements are not invented — they are inherited from the work of typesetters, typographers, and designers who refined the art of making text readable long before screens existed. From Gutenberg's movable type to Tschichold's asymmetric typography to Bringhurst's Elements of Typographic Style — postext aims to bring that accumulated craft to the web, where it has been conspicuously absent.
MIT
postext-foliopostext/worker runs the pipeline off the main thread with last-wins cancellation, also loaded straight from esm.sh.postext/react shows a document's pages in a component; the main entry never loads React.packages/typescript-config | Shared strict TypeScript configuration across all packages. |
postext-port agent skillpostext command line (#617) and WebMCP tools for agents in the browser