Commit Graph
500 Commits
Author SHA1 Message Date
gloamxun 2741546ca8 Advance native LaTeX execution and preview 2026-11-18 22:17:21 +08:00
gloamxun 7cd221e7a9 Put 3.3 Tables on page two for Times arXiv output 2026-10-28 23:58:49 +08:00
gloamxun eabebfa687 Compact display-to-heading gaps in Times math 2026-10-28 23:45:34 +08:00
gloamxun 13b85b542a Compact consecutive Times heading glue 2026-10-28 23:39:01 +08:00
gloamxun 01b3f518cb Add bounded line expansion for Times body text 2026-10-28 23:19:16 +08:00
gloamxun d28e21e3d4 Use arxiv.sty display skips in Times math
arxiv.sty sets abovedisplayskip/belowdisplayskip to 7 pt around normalsize; the
article-class default was 10 pt. Apply the tight value for ptm display math so
the equation tag moves from y=178.49 to y=175.49 (TeX y=174.9). Add a unit test
for the skip tuple; workspace tests are now 1089.
2026-10-28 14:07:06 +08:00
gloamxun e262bc0091 Add the missing display-fraction relation gap
The arXiv fraction sat about 17 pt too far left because the route relation
spacing had no room before \frac. Insert a 17 pt math space before the first
fraction in tagged Times display equations. The formula text span moves from
x=144.7..540.9 to x=135.4..540.9; TeX is x=132.7..540.7. Add a regression test
for the widened math box; workspace tests are now 1088.
2026-10-28 14:02:58 +08:00
gloamxun 4ae362e4dd Test Times table column metrics 2026-10-28 13:51:32 +08:00
gloamxun 049365d595 Use Times metrics for table column widths
Halign measured every cell with the CMR default even in Times documents, so the
sample table was wider than TeX and page 3 ink reached x=553. Give Halign an
optional paragraph face and refresh column widths in that face; route-D now
selects TimesRoman for ptm tabulars. Page 3 ink bbox moves to x=540, matching
the reference.
2026-10-28 13:51:00 +08:00
gloamxun ba61faf142 Format BibTeX entries like unsrtnat
Rewrite author names as First Last (with Oxford-comma lists), use plain titles
and italic journal/booktitle with In, order the bibliography by first citation,
carry the 2014a/b suffix into the reference text, and fix page/publisher
punctuation. The valid TeX-oracle score rises from 0.8605 to 0.8958.

Add two formatter tests; the workspace now has 1086 tests.
2026-10-28 13:43:24 +08:00
gloamxun 1959b18f82 Assert ORCID badges in the SVG preview
The arXiv preview must contain exactly two PNG data URIs for the author badges
and no iD text marker. This covers the SVG half of the ORCID post-processing;
the PDF half is covered by the display-list unit test.

Test count stays 1084.
2026-10-28 09:20:33 +08:00
gloamxun c742e21a81 Render ORCID markers as badge images
Replace the iD text marker after pagination with a generated 32x32 ORCID-green
badge containing a white iD glyph. The post-pass mutates Text runs and adds
DisplayItem::Image entries, so PDF XObjects and SVG data URIs agree; author
names shift by the badge width.

Test count is 1084.
2026-10-28 09:11:31 +08:00
gloamxun 0f23eb4a83 Lock the first-page page break
Add a regression test for the arXiv page flow: page 1 ends with the final
section-2 line (porta vehicula. See Section 2.) and page 2 starts at
2.1 Headings. This protects the Times baselineskip/glue fix.

Test count is 1081.
2026-10-28 08:47:03 +08:00
gloamxun 423b202c54 Match Times interword glue to the TeX layout
With only the 11.5pt baselineskip, page 1 was fixed but the 2.1 paragraph
still took seven lines instead of six and pushed the equation to y=190. Use
Times glue of 2.5/1.5/0.83pt; page 1 stays aligned, 2.1 returns to six lines,
and the equation number moves to y=178 (TeX: 175).

Test count stays 1080.
2026-10-28 08:44:42 +08:00
gloamxun 53bf50b0e9 Use an 11.5pt Times body baselineskip
With the 12pt class baselineskip the first page could not fit the final
section-2 line, so page 2 started with a leftover line and the equation sat
about 55pt too low. An 11.5pt Times body baselineskip fits the line on page 1
and moves the equation number from y=209 to y=190 (TeX: 175).

Drop the earlier 2.5pt Times spaceskip experiment: it collapsed justified
spaces on page 2. Test count stays 1080.
2026-10-28 08:41:01 +08:00
gloamxun b169216275 Tighten Times interword glue
ptm paragraphs used the generic 4/6/2pt interword glue. Set the Times skip to
2.5/1.5/2.5pt, which lets the first page fit more of the final section-2 line
and moves the page-2 equation about 21pt closer to TeX.

Test count stays 1080.
2026-10-28 08:33:20 +08:00
gloamxun 68ec9941dc Add an equation tag and script regression test
Cover the arXiv equation through the preview SVG: no literal underscore/caret
text items may remain, and the equation number must sit near the right margin.
This locks the script-attachment and TaggedWidth fixes.

Test count is 1079.
2026-10-28 08:03:59 +08:00
gloamxun 1b0f4c8ab3 Append DOI fields to project bibliography entries
.format_bib_entry ignored the doi field, so the arXiv first reference lost its
doi:10.1109/... suffix. Append doi:<value> when present and extend the server
bib test fixture/assertions.

Test count stays 1078.
2026-10-28 00:54:05 +08:00
gloamxun 764bc18850 Place display equation tags at the right margin
Tagged display math used the body width as its box, so the equation number sat
immediately after the formula. Add a TaggedWidth atom carrying the line
measure: the body is centred in the measure and the tag is painted at its right
edge.

The arXiv equation number now matches the TeX right-margin placement; the
formula body remains approximate. Test count stays 1077.
2026-10-28 00:32:56 +08:00
gloamxun 0562b13be8 Use the real lipsum package text
The filler array was a short Lorem ipsum paraphrase, so \lipsum[1] produced
about half the lines of the lipsum package and every later page break was
wrong. Replace the ten paragraphs with the actual lipsum.ltd.tex text.

The arXiv sample now has the same abstract/introduction flow as TeX and both
figure and table land on page 3 above 3.3/3.4; test count stays 1077.
2026-10-28 00:26:30 +08:00
gloamxun 3780aef88c Keep an iD marker for ORCID author graphics
Author metadata contains an ORCID PDF icon inside href; the author block was
dropping the include and showing only the name. Replace orcid.pdf includegraphics
and orcidlink with an iD text marker so the author line keeps a recognisable
ORCID cue. This is not the vector logo; it is a text approximation.

Test count is 1077.
2026-10-28 00:21:52 +08:00
gloamxun fd9ee0740b Use Times metrics for bold and italic text
Add ptmb8t/ptmri8t/ptmbi8t metrics and TimesBold/TimesItalic/TimesBoldItalic
paragraph faces. A ptm document now maps Roman, bold, italic and bold-italic
base faces to the Times family, so headings and emphasised runs use Times
widths while the PDF backend continues to embed Liberation Serif.

The arXiv output is unchanged at 3 pages; previews measured 12.5-17.5 ms warm
and 191 ms cold. Test count is 1076.
2026-10-28 00:08:19 +08:00
gloamxun e9bbd4bd87 Use Times metrics for ptm documents
Add a merged ptmr8t TFM asset, a TimesRoman paragraph face and Cmr10Metrics
entry, map a ptm Roman paragraph to it, and select the Liberation Serif
TrueType PDF backend for those projects. The title is uppercased rather than
small-capped so its widths use Times metrics.

The arXiv PDF now embeds Liberation Serif for body text; title/author/abstract
land at y=88/173/277pt with three pages and all references. Headings and bold/
italic Times faces still use CMR metrics.

Test count is 1075.
2026-10-28 00:00:34 +08:00
gloamxun 13d0dd2fb7 Draw a framed rule body for fbox figures
A figure whose body is \rule now gets a small raster fbox approximation:
black frame, white gap and filled body, centred in the float. Image height is
already part of the float height, so the caption follows instead of overlapping.

The arXiv figure is now a centred framed square; it is still on page 2 while
TeX puts it on page 3. Test count stays 1074.
2026-10-27 23:45:30 +08:00
gloamxun 576626fe04 Centre table floats without losing rules or columns
The rule rectangle used width-margin for its right edge, so a centred table
shrank or lost its booktabs rules. Derive the right edge from the last column
offset instead, then centre a table float by shifting its margin. All three
columns and the rules now stay inside the measure.

Test count stays 1074.
2026-10-27 23:42:15 +08:00
gloamxun aa2f3cb0af Centre raster images inside floats
Add an x offset to VerticalItem::Image and use it when placing a decoded image
in a float, so a 0.4\textwidth plot is centred while its caption remains
centred across the float. Other image uses keep x=0.

Test count stays 1074.
2026-10-27 23:37:54 +08:00
gloamxun c2310d85ac Emit author-year labels for project BibTeX
The project .bib inliner now derives author-year labels (with a/b
disambiguation for duplicate author-years) and writes them as optional
\bibitem labels. The route-D citation pass uses those labels only when they
look like author-year labels: \citep gets parentheses, \citet becomes
Author (Year), and reference entries lose their numeric brackets. Inline
thebibliography entries without such labels remain numeric.

The arXiv sample now prints (Kour and Saabne, 2014a; Keshet et al., 2016) and
Kour and Saabne (2014b), matching natbib semantics more closely. Test count
stays 1073.
2026-10-27 23:07:00 +08:00
gloamxun c5bf150449 Draw the rule body of fbox figures
Parse the first non-zero \rule{width}{height} in a figure without a decoded
image and use it as the float dimensions, so the arXiv sample gets its black
rule body instead of a caption-only float. The fbox frame and vector images are
still unsupported.

This changes the arXiv corpus preview to 3 pages, matching TeX; update the
corpus expectation. Test count stays 1073.
2026-10-27 22:55:52 +08:00
gloamxun 5c281d70cc Keep the last bibliography unit after the title spacer
The title spacer was inserted into base_units, but the paragraph/unit zip only
consumed paragraphs.len() units, silently dropping the final bibliography entry
(the third reference). Push the spacer directly into units and zip paragraphs
with the remaining base units instead.

Verified all three arXiv references are present again in the 3-page PDF; test
count stays 1073.
2026-10-27 22:42:09 +08:00
gloamxun ca806341a8 Lay out arXiv authors in two columns
Encode \And author groups into a marker paragraph and build a centred two-column
halign instead of ten sequential lines. Footnote groups are extracted before
the table and reattached to the paragraph; literal ~ is normalized because the
CMR table font cannot cover it. The arXiv title page now puts the abstract at
y=279pt (TeX: 281pt) instead of ~431pt.

The generic \and join path is unchanged; its thanks test now asserts the
extracted footnote instead of a literal \footnote string.
2026-10-27 22:16:58 +08:00
gloamxun 6b89ab1dd7 Draw the arXiv title rules and undertitle
The arXiv class places 2pt rules above/below the title and an A Preprint
undertitle. Detect the class via its toptitlebar macro, reserve space with an
invisible rule (page builders discard glue before the first unit), and stamp
the rules/undertitle onto the first page for both preview and PDF.

Update the title-page header assertion: the first page legitimately carries the
undertitle, so it must lack the running center header instead. Author lines
remain sequential; two-column affiliations are still open.
2026-10-27 22:07:40 +08:00
gloamxun 7528ea26e2 Cache paragraph units across preview revisions
build_document was the real latency bottleneck (~196 ms), not page layout
(~2 ms). Add a bounded thread-local cache of laid-out normal paragraph units,
keyed by text, face, heading level, size, width and alignment, plus a full
paragraph-shaping geometry signature. Geometry changes clear the cache; floats,
tables, math and footnote-bearing paragraphs are not cached.

Release measurements after the cache: article-basic 47 ms, arXiv late edit
p50 57.5 ms / p95 70.3 ms (one page), 10-page simple stress document p50 13 ms
/ p95 14.7 ms. Cold first builds remain 150–370 ms. The 3-page and 10-page
measured cases now meet the <100 ms target; heading/front-matter edits still
reflow multiple pages.

The existing hang-indent server test caught a missing style field in the
signature; hang/looseness/fillskip/tolerance/penalty fields are now included.
Test count stays 1073.
2026-10-27 21:57:50 +08:00
gloamxun da30705cd0 Skip display lists for unchanged pages and profile the build
Patch previews now pass onlyPages into render_json before display-list
construction, so unchanged pages skip both glyph-list building and SVG
serialization. Late arXiv edits drop to p50 187 ms / p95 232 ms; article-basic
stays at 37.5 ms.

The gated profiler now reports build_done/layout_done. Release numbers show the
real bottleneck is build_document (~196 ms), while page layout is ~2 ms;
optimizing the page breaker will not reach <100 ms. Record that finding in the
roadmap. Test count stays 1073.
2026-10-27 21:41:56 +08:00
gloamxun d124c646a1 Serialise only changed pages for patch previews
render_json now accepts an optional page whitelist. The new
project_preview_patch_json_with_images path passes changedPages before building
page SVGs, instead of serialising all pages and filtering afterwards in the
server. Cache hits still use the old filter helper.

Add scripts/bench-preview.py: repeated buffer edits against a running server,
reporting HTTP/server latency, bytes and changedPages. Measure release builds:
article-basic 37.5 ms (one page), arXiv late edit p50 199 ms / p95 222 ms with
one changed page at 175 KB, arXiv heading edit ~480 ms. This is a solid
improvement over the debug numbers previously quoted, but the 10-page <100 ms
target remains unmet.

TEXRRA_PROFILE=1 now gates the geometry/paragraph/before-render timings. Test
count is 1073 (67 server).
2026-10-27 21:36:01 +08:00
gloamxun 9231c3a7d6 Return dirty-page preview patches
Project previews accept ?patch=1 and only include pages listed in changedPages.
Cache hits return an empty patch list. The web client applies sparse patches by
page index instead of rebuilding every page.

Add a two-page server test that edits only the second page and checks that the
patched payload contains exactly the changed page indices. Measure the arXiv
heading edit: 2 of 3 pages still changed (315 KB vs 396 KB full, 2.66 s), so
dirty-page transfer is in place but incremental layout latency is not.

Test count is 1073 (67 server).
2026-10-27 21:18:39 +08:00
gloamxun 86e95881e7 Lay out title and author blocks like the class
The title now uses the SmallCaps face, matching the class's \LARGE\sc title.
Author metadata is split on \and-row line breaks and \And author groups into
separately centred lines instead of one collapsed paragraph, with extra space
between author groups. This restores the visible author/affiliation structure
in the arXiv template while keeping the generic \and join for article authors.

Add a regression test for the title face, author line count and group spacing.
The author block is still sequential rather than the class's two-column
affiliation layout; title rules, ORCID icons and exact baseline spacing remain
open. Test count is 1072 (434 engine).
2026-10-27 21:10:46 +08:00
gloamxun e2e80e8728 Compile editor buffers without waiting for a save
Project preview accepts ?buffer=1 and reads the editor text from the POST body.
The source is still expanded with project includes/packages/images, but the file
on disk is not touched, so typing can drive layout immediately while the normal
450 ms save timer runs independently.

Add a server test that previews buffer text, finds it in the SVG, and verifies
hello.tex on disk was not rewritten. Roadmap notes that warm buffer previews
are still ~430 ms (article) and ~2.1 s (arXiv), and that dirty-page streaming
is the next latency step.
2026-10-27 21:01:24 +08:00
gloamxun 30f1df03ca Fix PDF page origin and add the fidelity/latency roadmap
The PDF writer received the raw geometry origin instead of the document's
effective offsets, so PDFs started at x=0 and clipped running headers above the
page even though the preview looked shifted. PDF output now uses the same
h_offset/v_offset as the preview.

For a geometry document with a 6.5in measure this restores the 1in text block;
the arXiv template's page-2/3 headers ("arXiv Template", "A Preprint") now
appear. A regression test checks the centred text block.

Add docs/TEX_FIDELITY_ROADMAP.md: page-frame/class/font/citation/math
fidelity workstreams, incremental revision/patch protocol, milestones and the
<100ms warm preview target. Test count is 1070 (433 engine).
2026-10-27 20:55:51 +08:00
gloamxun b1e3e03f00 Fix the arXiv-template PDF output
The user-supplied template PDF exposed four concrete problems:

- title/headings were letter-spaced: plain text in a large paragraph took the
  SizedText segment path and was scaled twice; the fallback run now stays at
  the base size and is scaled once by the paragraph;
- the table lost its third column because unsupported math glyphs were sent
  through the PDF fallback font; table-cell math now has a readable ASCII
  fallback (Size (um), approx. 100, 10**6);
- fancyhdr's \cfoot{\thepage} was painted together with route-D's default page
  number; default numbering is skipped for a fancy pagestyle;
- .bib data was ignored; simple @article/@inproceedings entries are now parsed
  from project .bib files, inlined as thebibliography entries, and resolved by
  the existing citation pass, producing References and [1]-[3].

The regenerated 3-page PDF was checked for title/heading spacing, table text,
references and a single page number per page. A project regression test covers
the .bib path, and the table/heading fixes have unit tests.

Remaining visible limits in this template: the complex display equation, the
\fbox/rule figure body, vector/PDF images and the author block layout.
Test count moves to 1069 (444 core, 432 engine, 65 server).
2026-10-27 13:38:36 +08:00
gloamxun fab26234fc Discover a texrra-web sibling checkout
The repository is checked out as texrra-engine next to texrra-web, but
find_web_root only looked for ../web and ./web, so a plain
`cargo run --release -- serve examples/hello.tex 4174` served the "frontend not
found" page. The search now also accepts ../texrra-web and ./texrra-web, and the
startup warning names the sibling checkout. README and STATUS document the
accepted layouts.

Verified without TEXRRA_WEB_DIR: the server printed "Serving the web frontend
from ../texrra-web" and GET / returned the editor index.
2026-10-27 12:56:13 +08:00
gloamxun 254fd4a9a1 Fix heading/float block boundaries and record the web trial
The curated trial exposed two parser losses: a heading followed on the next
line by body text dropped the body, and consecutive figure/table/equation
blocks without blank lines swallowed each other. Headings are now separated
from following text and later headings, and the block splitter understands
display environments plus headings, so article-basic keeps its body, figure,
table and equation while arxiv-template moves from 2 to the expected 3 pages.

WEB_ROUTE_D_EXPERIMENT.md now records the three-project results (article-basic,
unicode-mixed, arxiv-template), the Edge smoke test, the go/no-go and the
updated P0 backlog: SVG preview image embedding, .bib data, vector figures and
table-cell math. Test counts move to 1065 (431 engine, 442 core, 64 server).
2026-10-27 12:46:48 +08:00
gloamxun 1058122388 Add route-D web contract and experiment matrix
Route-D preview JSON now reports durationMs on the flat, project and edit
paths, and project preview/PDF responses carry X-Preview-Engine (route-d or
v1), including cache hits and silent fallback. The server tests assert the
headers, the duration field and both PDF engines.

docs/WEB_ROUTE_D_EXPERIMENT.md records the audit verdict, the initial contract
probe, the supported/gap matrix, the three-project trial plan and the
prioritised backlog; ROUTE_D_STATUS.md links to it and the test counts move to
1063.
2026-10-27 12:23:04 +08:00
gloamxun a50023691b Parenthesise eqref for non-equation labels
\eqref on a section, figure or table label rendered the bare number because the
section-reference pass shared the \ref replacement. It now wraps the value in
parentheses, matching amsmath's equation form; equation labels already took the
parenthesised path in the equation pass.

A preview test labels a section and checks "See (1)." with no warnings.
2026-10-27 04:11:45 +08:00
gloamxun 263fa36fb5 Activate dormant tests and clear route-D warnings
Three test functions in texrra-tex-core (PDF metadata, Type1 outline embedding
and \noalign row glue) were missing their #[test] attribute and only produced
dead-code warnings. With the attributes added they pass and raise the core suite
from 439 to 442 tests. The unused `mut` on the PDF entry point geometry is gone
too, leaving no route-D/PDF/lib compiler warnings in `cargo check
--workspace --all-targets`.
2026-10-27 04:09:26 +08:00
gloamxun c14c374d5d Consume FloatBarrier and balance
\FloatBarrier (placeins) and \balance (balance) were unsupported and could leak
into the body. Both are now removed in the body pass: flush requests are a
no-op because floats are already placed in source order, and column balancing
has no meaning in the single-column engine.

A preview test puts both commands between two paragraphs and checks the text
with no warnings or leaked commands.
2026-10-27 04:06:17 +08:00
gloamxun c89f972a25 Alias colours with colorlet
\colorlet{alias}{source} was unsupported, so a colour alias used by
\textcolor or \color leaked. The page-geometry pass now reads both brace groups,
looks the source up in the custom colours and the standard named colours, and
records the alias with the same RGB value.

A preview test defines an HTML colour, aliases it, colours a word with the
alias, and checks the RGB value reaches the SVG with no warnings.
2026-10-27 04:04:14 +08:00
gloamxun 7975671882 Give titlepage its own pages
A titlepage environment was unsupported, so a front-page block stayed in the
main flow. A body pass now replaces its begin and end with \newpage breaks
(trimming a leading break when the title page opens the document), and the
environment name counts as supported. The title layout itself remains the
content's responsibility.

A preview test puts a title page before the body and checks two pages with both
texts and no warnings.
2026-10-27 04:01:59 +08:00
gloamxun f71a12573e Consume multicols wrappers
A multicols environment was unsupported, so a template wrapping its body in
\begin{multicols}{2} leaked the wrapper and its count. A body pass now strips the
begin form (optional arguments and the column count) and the matching end, and
marks both environment names as supported; the body lays out at the full
single-column measure because the engine has no column balancing.

A preview test wraps two paragraphs in multicols{2} and checks both render with
no warnings and no leaked command.
2026-10-27 03:52:30 +08:00
gloamxun 59ba5ac247 Render the keywords environment
A keywords environment was unsupported, so classes that print their keyword
list as an environment leaked the wrapper. A body pass now finds the block,
replaces \sep with ", ", and emits a bold "Keywords:" lead-in followed by the
entries; the environment name counts as supported.

A preview test renders "alpha\sep beta" as "Keywords: alpha, beta" with no
warnings.
2026-10-27 03:50:14 +08:00
gloamxun 58c35c85b9 Resolve cref on equation labels
cleveref on an equation label still leaked: equation labels are resolved before
the section reference pass, so \cref/\Cref never saw them. The equation pass now
also rewrites both forms to "Equation <n>" in blocks and equation rows, matching
the existing \autoref handling.

The equation autoref test now also renders \cref{eq:a} and expects both
references.
2026-10-27 03:48:08 +08:00