Repository navigation
feat(docs): add opt-in Typst content guards - #2019
Merged
Merged
Conversation
gerchowl
force-pushed
the
feature/1994-typst-content-guards
branch
from
November 4, 2026 01:33
a2c773b to
7a7e97e
Compare
Archive the unchanged 0.2.0 package and verify normal 0.2.1 output against it. Refs: #1994
gerchowl
force-pushed
the
feature/1994-typst-content-guards
branch
from
November 4, 2026 03:18
7a7e97e to
1490cf8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add docs-only content checks for missing figure captions, missing table headers, direct page/font overrides, and SVG lettering below 7 pt at its placed size. The shared hook supports skip globs and end-of-line suppression with source diagnostics.
Type of Change
feat-- New featurefix-- Bug fixdocs-- Documentation onlychore-- Maintenance taskrefactor-- Code restructuringtest-- Adding or updating testsci-- CI/CD pipeline changesbuild-- Build system or dependency changesrevert-- Reverts a previous commitstyle-- Code style changesModifiers
!)Changes Made
Add
typst-contentthrough the shared docs hook definition and portable asset; keep non-docs hook configuration unchanged.Query compiled content once per entry in one shared ephemeral mirror, with source diagnostics and at most two compiler workers. Preserve native image values and validate a clean original compile before falling back from instrumentation failures or warnings.
Resolve literal and variable image paths relative to their containing source and retain generated assets. Honor table suppression without derived-table duplicates, detect multiline function/closure template overrides, and scope duplicate-label/fallback suppression to individual calls in dependency/document order.
Preserve markup and caption prose around inline expressions so grid/column measurements stay instrumented, while retaining multiline and imported closure checks.
Attribute logos only to direct document-template parameters and measure each logo/body placement independently; dictionary keys cannot supply logo attribution. Instrument only compiler-reported dependency sources with indexed scanning, linear edit assembly, and cached dependency-edge tokenization.
Measure SVG fit, nested SVG/symbol viewports, inherited font units, height-only sizing, visible text and used definitions. Resolve CSS font shorthand from Matplotlib 3.6–3.9 and the 3.10 font-size form with the normal cascade and
!important; warn on unresolved sizes and bounded use expansion. Accept Matplotlib DOCTYPEs while blocking entities/external references; warn per placement for Typst scale transforms.Ship package 0.2.1 with guard-only layout measurements for percentages, automatic sizing, grids, columns and figure bodies. Archive the exact shipped 0.2.0 source and retain historical imports and hashes.
Document fallback sizing, unresolved-size warnings, SVG limitations and suppression. Add a dedicated sandboxed compiler contract and a reproducible medium-document benchmark.
Track code and markup with one structural tokenizer, including multiline else chains, smart quotes, URLs, escaped hashes and qualified builtin calls. Reuse its modes, delimiters and comments for instrumentation.
Record effective paper, margins and font in guard-only package contexts at page starts and headings. Report runtime bypasses by page; document the entry-level runtime suppression marker.
Warn on incomplete CSS blocks and cap selector/node work at 1,000,000, including repeated reference visits.
Changelog Entry
Added
Testing
just test); delegated to CI as required by the task brief.Manual Testing Details
nix build .#checks.x86_64-linux.typst-content .#checks.x86_64-linux.typst-house-style --no-link --max-jobs 1 --cores 2 -L: exit 0. Includes 115 content compiler contracts, 165 house-style tests, the remaining native/layout contracts and 21 killed style mutants.uv run python packages/vig-utils/tests/benchmark_typst_content.py --entries 1 --figures-per-entry 4000 --unrelated-files 0measured 60.567s before and 21.052s after, both exit 0. This round adds a source-tokenization count regression and caps CSS cascade work at 1,000,000 selector/node evaluations, including repeated references.1490cf833f09e1d94c4902354f980f609b5eb759. CI including Test Summary, Home Matrix, and CodeQL completed successfully.Current local pytest commands (each exit 0):
Checklist
Additional Notes
Relative and automatic sizing without package metadata uses the documented page-width fallback. Unresolved sizing/font shorthand, unsupported SVG styling, scale transforms and SVG use expansion limits emit named warnings. SVG traversal is capped at 32 reference levels and 32,768 visited nodes, including repeated reference contents. Unsupported uppercase font properties, declaration comments and spaced importance markers warn explicitly. Images from bytes have no inspectable source path and are documented as skipped. Raster images and lettering converted to outlines cannot be measured. Rebased onto #2017; retain the released 0.2.0 source and hash while shipping guard instrumentation in 0.2.1.
The retained 0.2.0 package is an unchanged archive of previously reviewed source from #2017. Shared defusedxml is retained so dynamically activated docs hooks and recipes always use the same hardened parser without a second Python environment; the dependency tradeoff is documented in both CHANGELOGs.
Refs: #1994