Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

@pretextbook/pretext-html

Latest version: v0.21.3

Overview

Last scanned
26 Nov 2026
Published
26 Nov 2026
npm package Publisher: oscarlevin
14 Stars
14 Forks
19 Versions
1.4K Downloads
XSLT Repo language

Scan summary

@pretextbook/pretext-html was last scanned on 26 Nov 2026 at version 0.21.3. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 19 versions; the latest 2 were published within 2 days (25 and 26 Nov 2026).
  • Findings: No rules fired in version 0.21.3.
  • Downloads: 1,409 downloads.

Versions

19 versions published
Versions and the rules that fired in each
VersionPublishedStatus
0.21.3 LATEST 26 Nov 2026 No rules fired
0.21.2 25 Nov 2026 No rules fired
0.21.1 14 Nov 2026 No rules fired
0.21.0 11 Nov 2026 Not shown
0.20.0 11 Nov 2026 Not shown

No rules fired in 0.21.3

Findings

Findings for v0.21.3. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 0.21.3; other versions have their own rules, not their own score.

README

The publisher’s own README, as collected from the registry.

@pretextbook/pretext-html

Convert PreTeXt documents to HTML in pure JavaScript — no Python, no PreTeXt installation. This runs the official, unmodified PreTeXt XSLT stylesheets with @pretextbook/libxslt-wasm, a WebAssembly build of libxml2/libxslt/libexslt (the same C libraries the Python CLI uses via lxml), so the HTML matches a real pretext build. It is a fork of jeremy-code/libxslt-wasm built with a larger WASM stack so whole-book documents render without overflowing (see Forking libxslt-wasm).

The output is a single, standalone HTML page. The theme css/js and MathJax load from public CDNs, the whole document is rendered as one page, and images are linked rather than embedded, so the host serves them from wherever it keeps them (see Images and other assets). This is what powers the "Live Preview" in the PreTeXt-tools VS Code extension, and it is published so other tools (e.g. pretext.plus) can render previews the same way.

Usage

CLI
npx @pretextbook/pretext-html source/main.ptx \
  --project-dir . \
  --publication publication/publication.ptx \
  -o preview.html

HTML goes to stdout (or --output); diagnostics (PTX:WARNING, PTX:ERROR, deprecation notices) go to stderr. Run pretext-html --help for all options.

The CLI relaunches itself with --experimental-wasm-jspi automatically (see Requirements).

API (Node)
import { renderHtml } from "@pretextbook/pretext-html";

const { html } = await renderHtml({
  sourcePath: "source/main.ptx", // root document
  projectDir: ".", // directory the transform may read from
  publicationPath: "publication/publication.ptx", // optional
  stringParams: {}, // optional extra XSLT stringparams
});
  • sourceContent lets you render unsaved editor text (with sourcePath still anchoring relative xi:includes).
  • fragment: true renders a non-root file (a lone <section>, <chapter>, …) by wrapping it in a minimal <pretext> document. To keep the project's LaTeX macros and custom settings, give it the docinfo: either docinfoSourcePath (the project main file, whose <docinfo> is lifted out — resolving xi:includes, including a docinfo that is itself included), or docinfo (a <docinfo> element as a string, if you already have it). Both are ignored for complete documents, which carry their own docinfo.
  • sourceMap: true additionally returns a source map for editor/preview sync: one entry per element, in document order, mapping the element's HTML id to the source file/line it was authored in — through xi:includes. This works because HTML ids are the @unique-id values that pretext-assembly.xsl stamps with a deterministic walk (@label ?? @xml:id ?? parent-id + "-" + sibling-position), which is replicated over the merged tree in JS; the rendered page itself is unchanged. Entries carry a parent id so clients can fall outward when an element has no HTML id of its own, and findSourceMapEntry(entries, line) picks the element nearest a cursor line. (This powers the two-way sync in the VS Code Instant Preview; the same map works for any embedder.)
  • The user's publication file is respected, except for four settings that single-page in-memory output needs, which are always forced (see src/publication.ts):
    • <html><resources host="cdn"/>: css/js, theme and icon font from the CDN.
    • <common><chunking level="0"/>: the whole document on one page.
    • <html><cross-references knowled="never"/>: cross-references are links, because the knowl files they would open are never written.
    • <html><platform portable="no"/>: PreTeXt's portable HTML mode is off, even for a project that builds portable. Portable mode would do the first three as well, and earlier releases relied on it, but it also inlines every latex-image and PreFigure SVG into the page. Without it those are linked like every other image.
    • <html><search variant="none"/>: no search box and no search index. The index is a separate file a preview never writes, and building it costs a walk over the whole document on every render.
  • cssTheme: "denver" supplies the PreTeXt HTML theme for projects that do not choose one, by adding <html><css theme="…"/></html> to the publication file used for the build (including the minimal one synthesized when you pass no publicationPath). It is a default, never an override: a publication file that already names a theme — @theme, or the deprecated @style/@shell — keeps it, so the preview goes on matching what pretext build produces. The themes the bundled stylesheets know are default-modern (PreTeXt's own default), denver, tacoma, salem, greeley and boulder; the preview loads theme-<name>.min.css from the CDN, so an unrecognised name gives an unstyled page. Not to be confused with theme below, which is the light/dark mode within whichever css theme is in force.
  • The compiled stylesheet is cached per xslDir (~1s to compile, then ~100ms–1s per render depending on document size).
  • theme: "dark" | "light" | "system" makes the preview follow the embedding app's light/dark theme (see Theme control).
  • Born-hidden knowls — solutions, hints, answers, and any block the publication file elects to hide — are rendered expanded, because these pages are previews: an author editing a solution would otherwise watch it collapse on every re-render. Other <details> (footnotes, image descriptions) are left alone. Pass openKnowls: false (--no-open-knowls on the CLI) for the collapsed reading experience of a real pretext build.
Images and other assets

Every image the page shows is an ordinary link under one of two fixed prefixes, exactly as in a real build. Author-supplied files are under external/, and everything pretext generate makes (latex-image, PreFigure, sageplot, asymptote, …) is under generated/:

<img src="external/kitten.png" />
<img src="generated/latex-image/diagram.svg" />

A real build copies both directories next to its pages. A preview has no such directory, so the host maps each URL to wherever it keeps the file:

import { renderHtml } from "@pretextbook/pretext-html";
import {
  rewriteAssetUrls,
  missingAssetPlaceholder,
} from "@pretextbook/pretext-html/assets"; // dependency-free subpath

const { html, assetDirs } = await renderHtml({ sourcePath: "source/main.ptx" });

const page = rewriteAssetUrls(html, (kind, relPath) => {
  // kind is "external" or "generated"; relPath is e.g. "latex-image/diagram.svg"
  const url = lookUp(kind, relPath); // a webview URI, a blob URL, a hosted URL…
  return url ?? missingAssetPlaceholder(kind, relPath);
});
  • assetDirs gives the absolute directories behind the two prefixes, resolved the way PreTeXt resolves them. external comes from the document's <docinfo><directories external="…"/>, falling back to the publication file's deprecated source/directories/@external; it is absent when neither declares one, which PreTeXt reads as "no external assets". generated comes from the publication file's source/directories/@generated and defaults to generated/ beside the main source file.
  • A host without a filesystem (a browser editor) ignores assetDirs and answers from its own store of uploaded or generated files. Nothing reads image files during the render itself.
  • Give a file a new URL when it changes, for instance with a version or modification-time query. A page never fetches an <img> again while its src is unchanged, and a live patch leaves an unchanged element alone, so a regenerated image behind the same URL keeps showing the old picture. With a new URL, a live patch updates just that src in place and only that image reloads. Re-deliver the page when the files change (the VS Code preview watches the asset directories), not only when the source does.
  • missingAssetPlaceholder returns a data-URI SVG that names the missing file and says what to do (pretext generate latex-image, or "check @source"), which reads better than the browser's broken-image glyph. Return undefined from the resolver instead to leave a URL as it is.
  • Only src attributes are rewritten. An annotated PreFigure diagram (one with <annotations>) is drawn by a script from data-src/data-cml attributes, which are left alone.
  • The CLI applies this itself when it writes a file (--output), linking each asset relative to the output file. HTML written to stdout keeps PreTeXt's own URLs.
Interactives

An <interactive> that PreTeXt points straight at a service — @desmos, @calcplot3d, @circuitjs, @iframe — is an ordinary <iframe> on the page and needs nothing from the host.

One authored with @platform (GeoGebra, JSXGraph, D3, Sage, DoenetML, plain JavaScript), and <interactive geogebra="…">, which PreTeXt rewrites into that form, is different: the page holds <iframe src="<id>-if.html">, and a real build writes that second, minimal page — the slates, the platform's libraries, the author's scripts — to a file beside it. This renderer writes no files, so it returns those pages instead:

const { html, iframePages } = await renderHtml({ sourcePath });
// iframePages: { "graph-if.html": "<!DOCTYPE html>\n<html>…", … }

html is left with the iframes exactly as PreTeXt emits them, pointing at files that do not exist until the host does one of two things:

  • Serve them at those names, relative to wherever the page is loaded from.
  • Inline them with embedIframePages, which gives every iframe that names a page that page as its srcdoc (moving the filename to data-ptx-iframe-page). This is what the CLI does.
import { embedIframePages } from "@pretextbook/pretext-html/iframe-pages";

const page = embedIframePages(html, iframePages, { sandbox: "allow-scripts" });
  • An iframe page runs JavaScript the author wrote, and a srcdoc frame shares its embedder's origin. A host that shows documents its user did not write, on an origin that matters (a web app with a session), should pass sandbox without allow-same-origin. Omitted, the frame is unsandboxed, as in a PreTeXt build.
  • A page links its own assets (<interactive source="board.js"> becomes <script src="external/board.js">), and a srcdoc frame resolves those against the embedding page's URL. To send them elsewhere, run each page through rewriteAssetUrls before embedding it.
  • The helper is also on the ./iframe-pages subpath, free of the WASM renderer, for a host that inlines pages a worker rendered.
  • The reader-facing standalone page ("open in new tab") is still not built; its link is inert like every other off-page link.
Previewing one division of a large document

A render costs what PreTeXt's assembly costs, and that tracks the number of elements in the document: a few hundred milliseconds for a chapter, tens of seconds for a whole book. A live preview of a large document therefore should not render the whole document, and need not: the subtree option renders one division of it, numbered and cross-referenced exactly as the whole document would number it, by pruning the rest to a skeleton (see src/skeleton.ts).

const { html, size, subtree } = await renderHtml({
  sourcePath: "source/main.ptx",
  subtree: {
    line: cursorLine, // the division around the author's cursor...
    file: cursorFile, // ...in this file (defaults to sourcePath)
    level: 2, // chunk level: sections of a book are pages of their own
    wholeDocumentUpTo: 3000, // but a small document previews whole
  },
});
  • line/file select the innermost division containing a source line; id selects by xml:id instead (an element inside a division selects that division). The division need not carry an xml:id of its own — the one PreTeXt would stamp on it is injected, so the page's HTML ids are unchanged.
  • A division that contains divisions is previewed as a summary page: its own content (introduction, conclusion, loose paragraphs) rendered in place, then links to the divisions inside it, as the chapter page of a chunked build summarizes its sections. Only leaf divisions render in full, so a cursor at the top of a book shows the book's front matter and a table of its chapters, never the book. The summary links are inert on a one-page preview but carry data-ptx-division (and data-ptx-id for a link to an element), so a host can make them re-render with subtree: { id }.
  • level has PreTeXt's chunk-level meaning, for a host that wants whole pages at some depth: the preview is the page that would hold the selection in a build chunked at that level. A selection deeper than level previews its ancestor at level, whole; one at level is shown whole; one shallower is the summary page above. Omit it to treat every division as a page of its own.
  • wholeDocumentUpTo renders the whole document instead when it has no more than that many elements — a small document previews whole as fast as any division of it would.
  • Every result carries size (elements, bytes, and the files the document spans, to watch for changes), and subtree (id, level, collapsed) when one division was emitted rather than the whole document. measureDocument(options) reports the same size without rendering, for a host deciding how much to preview before each render.
  • With fragment: true and a context document, subtree narrows the preview within the placed fragment — a cursor line in a chapter file previews the section it is in.

What a division preview still has to do on every render is read and parse the whole document, to prune it. Two options keep that cheap:

  • readSource(path) (or files, a map from absolute path to content) supplies the document's files from memory — the xi:include targets, the context document, the publication file — for a host that already holds its project in memory (a browser editor) or has unsaved buffers (an editor). A reader that returns undefined for a path falls through to the platform's own read.
  • A per-file parse cache, on by default, reuses the parse of every file whose content has not changed since the last render. It is keyed by file, not by the assembled document, so it does not matter how the project is split into files: a keystroke re-parses the file being edited and nothing else. Pass a SourceCache of your own as cache to scope it (and invalidate() it), or cache: false to parse afresh each time.

On a synthetic 12-chapter book of 28,000 elements split into 157 files, a section or subsection preview takes well under a second warm (0.3–0.8s measured, most of it the division itself), and a chapter's summary page about the same, against 20–40 seconds for the whole book.

API (browser)

The same renderer runs in a browser — no server, no Python. Bundlers pick it up through the browser export condition automatically; there is nothing to configure.

import { renderHtml, isJspiAvailable } from "@pretextbook/pretext-html";

if (!isJspiAvailable()) {
  // No WebAssembly JSPI in this engine — fall back to a server-side build.
}

const { html } = await renderHtml({
  sourcePath: "/source/main.ptx", // a *virtual* path: no filesystem is read
  sourceContent: editorText, // required in the browser
  projectDir: "/source",
  fragment: true, // rendering one division on its own
});

Differences from the Node API, all of them consequences of there being no filesystem:

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • npm @pretextbook/pretext-html

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Copy of Template Design OX Blog (2)
Research

NGINX2Root: Five Critical NGINX Flaws Expose Web Servers to Remote Code Execution

Cry2Wolf: How to Tell a Real Bug from a Nothingburger
AI & VibeSec

Cry2Wolf: Not Every Branded Bug Deserves a Fire Drill

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Vulnerability Insights

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?

Frame 2085668439 (1)
Group 1261154229