Repository navigation
Packages
Postext is published as six npm packages that share one layout. postext lays the document out; the others read the result. The monorepo also holds the Sandbox component and the website (see Project Structure).
| Package | Version | What it does |
|---|---|---|
postext |
1.16 | The layout engine, plus canvas and HTML renderers, the layout worker, .postext bundles and a React component. |
postext-pdf |
1.16 | Print-ready and accessible PDF. |
postext-epub |
0.2 | EPUB 3, fixed layout or reflowable. |
postext-folio |
0.5 | A 3D book viewer on three.js. |
postext-citeproc |
1.16 | Citations and bibliographies in CSL styles. |
postext-cli |
1.22 | The postext command line, as one self-contained executable per system (also on each GitHub Release). |
postext-sandbox |
— | The Sandbox editor as a React component (used by postext.dev, not published to npm). |
@postext/typescript-config |
— | Shared TypeScript settings (internal). |
All packages are ESM only and written in strict TypeScript. Each can also be imported from esm.sh (https://esm.sh/postext, https://esm.sh/postext-pdf, …).
The core. Enriched markdown and a configuration in, a laid-out VDTDocument out.
| Entry | Contents |
|---|---|
postext |
buildDocument, the canvas renderer (renderPage, renderPageToCanvas, renderToCanvas), the HTML renderer (renderToHtml, renderToHtmlIndexed), the parser, defaults and resolvers for every configuration section, the math engine, hyphenation, warnings, outlines, bundles (re-exported) and the citation engine registry. |
postext/worker |
createLayoutWorker(): layout on a Web Worker with last-wins cancellation and font transfer. |
postext/worker/entry |
The worker script itself, for bundlers that need its URL. |
postext/bundle |
.postext files: openBundle, createBundle, buildBundle, font and image adapters, the zip codec and configuration migrations (migrateConfig, CONFIG_VERSION). |
postext/react |
createLayout(content, config): a component that shows the pages. |
Dependencies: @chenglou/pretext (measurement), Hypher with TeX patterns (hyphenation), MathJax (maths, bundled and loaded on demand), gray-matter (frontmatter). Peer: react ≥ 18, used only by postext/react.
Source: packages/postext.
Writes a VDTDocument, or a book's chapters, as PDF: embedded and subset fonts with kerning, HarfBuzz shaping for Arabic, vector SVG figures and PDF print masters, outlines, links, page labels, RGB/CMYK/grayscale, crop marks, and tagged PDF/UA-1 output.
| Entry | Contents |
|---|---|
postext-pdf |
renderToPdf(doc, options), decompressWoff2, svgToVectorDrawing, the PdfFontProvider and warning types. |
postext-pdf/worker |
createPdfWorker(): the same render on a worker. |
postext-pdf/worker/entry |
The worker script. |
Built on pdf-lib, @pdf-lib/fontkit and wawoff2 (patched in patches/ for bundlers). Peer: postext of the same major. Source: packages/postext-pdf. Guide: Generating PDFs.
Writes a book as EPUB 3.3, in the browser or in Node: a fixed layout (pre-paginated, every printed page with real text) or a reflowable book in semantic XHTML. Fonts, navigation, print page markers, right-to-left books and accessibility metadata; checked with EPUBCheck.
| Entry | Contents |
|---|---|
postext-epub |
renderToEpub(chapters, options), readEpub (for viewers), packEpub, buildFixedPublication, buildReflowablePublication. |
postext-epub/worker |
createEpubWorker(). |
postext-epub/worker/entry |
The worker script. |
Peer: postext. Source: packages/postext-epub. Guide: EPUB books.
Shows a laid-out document, or any set of page images, as a book whose leaves curl and cast shadows in three.js. Left- and right-bound books, paper stocks, lighting, tilt; pages are painted on demand around the open spread.
Exports createFolioFromDocument, createFolio (from page images), PageFlipper, FlatPageFlipper (a flat light table), spreadsOf, paperSpec, FOLIO_CSS. Peers: postext, three ≥ 0.160. Source: packages/postext-folio. Guide: A 3D book.
Formats the citations a document writes in Pandoc syntax with citeproc-js and builds the bibliography. Bundles 19 CSL styles (APA, Chicago, Harvard, ISO 690, GB/T 7714 2015 and 2025, MLA, IEEE, Vancouver, AMA, Nature, OSCOLA…) and 12 CSL locales; any other CSL style can be passed whole.
| Entry | Contents |
|---|---|
postext-citeproc/register |
Registers the engine with Postext. Import it once, or hand setCitationEngineLoader(() => import('postext-citeproc/register')) to load it only when a document cites. |
postext-citeproc |
createCiteprocEngine, STYLES, LOCALES, STYLE_CATALOG, parseBibtex. |
postext-citeproc/catalog |
The style list alone, for a picker. |
The package is MIT; citeproc-js is CPAL 1.0 / AGPL 1.0 and the styles and locales are CC BY-SA 3.0 (see its THIRD_PARTY_LICENSES.md). Guide: Citations.
The postext command: pdf, html, epub, image, images, docx, import-docx, pack, unpack, info, check and build --watch, from a .postext bundle, a book folder or loose Markdown, with --json reports and stable exit codes for scripts and agents. Bun compiles it with the engine, the writers, Skia (@napi-rs/canvas), HarfBuzz, the ICC profiles and the default fonts into one executable per system: macOS arm64 and x64, Linux x64, arm64 and musl, Windows x64. Every release attaches them to the GitHub Release with SHA256SUMS and readme.txt; on npm, postext-cli is a launcher whose optional dependencies postext-cli-<system> carry the executables. Source: packages/postext-cli. Guide: Command Line.
The editor at postext.dev/en/sandbox as a React component (<PostextSandbox />): library of books, markdown editor, Design and Resources panels, Canvas / PDF / Folio / HTML / EPUB previews, checks and storage in IndexedDB. See Sandbox, Standalone usage.
-
postext,postext-pdf,postext-citeprocandpostext-clishare a version number (the command line carries the engine it was built with);postext-epubandpostext-foliohave their own. A companion package needs thepostextit was released with, or a later one of the same major, so upgrade them together. - Releases are automatic. Merging
developintomainruns the Release workflow, which bumps every package (patch by default,minorormajorfrom the PR label), builds and tests them, publishes them to npm, builds the command-line executables (tested on Linux, Alpine, macOS and Windows and attached to the GitHub Release) and regenerates the showcase layouts. See Development Setup. -
.postextbundles and stored configurations carry aconfigVersion;migrateConfigkeeps books written by older releases laying out as they did.
Postext is MIT-licensed. Maintained by Ignacio Ferro and community contributors. See the live documentation for the most up-to-date reference.
Overview
Writing
- Document Format
- Hyphenation and Justification
- Chinese Layout
- Arabic Layout
- Japanese Layout
- Comics
- Composed Pages
- Sandbox
- Agent Skill
- Command Line
- WebMCP
Configuration
- Overview and index
- Page and layout
- Headers and footers
- Body text
- Hyphenation and language
- Headings
- Widows, orphans and balancing
- Lists and maths
- Notes and references
- East Asian typography
- Resources
- Styles and parts
- Callout boxes
- Comics
- Composed pages
- Fonts, colours, viewers
Code
Internals
External