Skip to content

Test that text survives the LaTeX and Typst round trip - #136

Open
soodoku wants to merge 1 commit into
py-econometrics:mainfrom
finite-sample:test/pdf-text-roundtrip
Open

soodoku wants to merge 1 commit into
py-econometrics:mainfrom
finite-sample:test/pdf-text-roundtrip

Conversation

@soodoku

@soodoku soodoku commented Nov 9, 2026

Copy link
Copy Markdown

Part of #135 (step 4).

What problem do you want to solve?

The compile tests run on one plain table, so they can't tell whether text with markup characters reaches the PDF intact. Text that changes silently still compiles: in LaTeX, set {a} prints as set a, and p < 0.07 prints as p ¡ 0.07.

What this adds

tests/api/test_output_formats.py gets a round-trip matrix:

  • Inputs: 12 strings, each with one markup character (% & _ # $ { ^ ~ < @ * [).
  • Placement: each string goes into the caption, the notes, a coefficient label and a model head.
  • Formats: LaTeX and Typst, which makes 96 cases.
  • The check: each case compiles, then checks with pdfplumber that the PDF text contains the string, with whitespace removed.
  • Avoiding false matches: each string carries a word that appears nowhere else in the table, and the other parts get a neutral note. My first version matched the default note's p < 0.1, which made three LaTeX cases pass for the wrong reason.

Results on main: 46 pass, and 50 fail. The 50 are marked xfail(strict=True) with their cause:

Format Failing on main Cause
LaTeX % & _ # $ { ^ ~ < in all four parts (36) no escaping; notes-percent is #99
Typst $ ~ @ in all parts, * in caption and model head (14) fixed by #122

I ran the matrix against the #99 and #122 branches. #99 turns exactly notes-percent into an unexpected pass, #122 does the same for exactly its 14 Typst cases, and neither causes a new failure. Because the markers are strict, whichever of those PRs merges after this one has to drop its markers. I'll push that change.

Tests

  • Full suite: 544 passed, 50 xfailed.
  • pre-commit and ty are clean.
  • No snapshots change.
  • The suite runs about 30 s longer locally (96 compiles). The LaTeX cases skip where pdflatex isn't installed, as the existing compile tests do.

🤖 Generated with Claude Code

Put strings with markup characters into the caption, notes, coefficient
labels and model heads, compile tex and typst, and check that the PDF
text contains them. Cases that fail on main are strict xfails naming
the cause, so each one has to be unmarked when its fix lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant