fix(html): give a paragraph its own font, and an empty one a line break - #687
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ca4e6ae961
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
andiwand
force-pushed
the
fix/paragraph-own-font
branch
from
August 11, 2026 20:03
ca4e6ae to
2b19522
Compare
`x-p` collapsed to `font-size:0` and an empty paragraph carried an empty span to stand in for its height. A run naming no size of its own then inherited nothing and rendered at zero - one pptx in the corpus reads as eleven blank slides. The paragraph states its font instead, which sizes the line it gives an empty one, and a run without a font of its own inherits it. What paints - a background, an underline - stays on the run, where it covers the text and not the line. An empty paragraph ends in a line break rather than a break opportunity: only a break is copied, so a blank line survives being pasted elsewhere. Emptiness is read through the wrappers a file may leave behind - a bookmark, or a span or link holding nothing - which is what the removed TODO asked for. Fixes the two TODO examples: `style-missing+image-1.odt`'s first paragraph goes from 0 to 18px, and the line break missing from `encrypted-exception-3$aabbcc$.odt` was a paragraph collapsed to 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QVkpzsGS6YASMqm3NwmWib
andiwand
force-pushed
the
fix/paragraph-own-font
branch
from
August 11, 2026 20:10
2b19522 to
d1d62ac
Compare
andiwand
enabled auto-merge (squash)
August 11, 2026 20:12
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.
Stacked on #686. Implements the empty-paragraph rework we measured out, and fixes a live bug it exposed.
The mechanism it replaces
x-pcollapsed tofont-size:0and every empty paragraph carried an empty<x-s>to stand in for its height. Removing each piece in turn shows both were load-bearing — a 14pt line is 22px:<x-p><x-s style="font-size:14pt"></x-s><wbr></x-p>(before)<wbr><x-s>The bug it caused
font-size:0is inherited, so a run naming no size of its own computed to0px. Walking every run in the corpus for its effective size, then confirming in the browser: 11 pages ofpptx/2025-09-11.15_35_15.pptxrendered text that was there but invisible — the reference output blessed eleven blank slides. Now visible.What this does instead
The paragraph states its own font (
translate_block_font_style), which sizes the line it gives an empty paragraph and is inherited by a run that names none. Only the font travels: a background painted on a block covers 756px of line where the run covers 42px, so anything that paints stays on the run.An empty paragraph ends in
<br>rather than<wbr>, because only a break is copied:"Alpha\nBeta"— blank line lost<wbr>"Alpha\nBeta"— blank line lost<br>"Alpha\n\nBeta"✓On real documents:
about.odtgoes from 1 to 9 blank lines in a select-all copy (10 empty paragraphs),15KB.docxfrom 0 to 9 (12), with every empty paragraph still visible at unchanged height.A bookmark does not count as content, which is what
// TODO if element is content (e.g. bookmark does not count)asked for. Both TODO examples are fixed:style-missing+image-1.odt's first paragraph goes 0 → 18px, and the "missing line break" inencrypted-exception-3$aabbcc$.odtwas an empty paragraph collapsed to 0, now 16px.No JS is needed for the
<br>: typing into an empty paragraph makes Chrome remove it (<br>→X, still 22px), and deleting a paragraph's text makes Chrome insert one —<br>is the filler engines already use for an empty editable line. Verified in Chrome only.Verification
Note
compare-htmlcannot verify the CSS half of this: it short-circuits byte-identical files without rendering them (see the correction in #685). The pptx fix is exactly such a case — its html is unchanged and only the stylesheet makes the text appear. So both sides were rendered and compared as pixels.Of 228 public pages, 40 differ. All are the intended change or known noise:
about.odt2408 → 2415,file-sample_500kB.odt3721 → 3952) — empty paragraphs that collapsed to 0 now occupy their line.overflow.ods-style fixtures whose overlapping text stack is slightly shorter.Reference output regenerated and pinned:
1964c34(185 files over two commits) and the private equivalent5e5f035(301 files). Pre-existing resource drift from #679/#682/#683 was left alone rather than swept in, soresources/moves only indocument.cssandspreadsheet.css.translate_block_font_stylegets three unit tests next to the existing inline-expectation ones; 864 tests pass.Worth a second opinion
The sheet baseline shift is the one judgement call. Emitting
font-sizealone and leavingfont-familyoff would keep sheets pixel-identical, but the strut's height depends on font metrics, so the family is part of getting an empty paragraph's height right. Say the word and I'll narrow it.Review follow-ups
Both P2 findings from the Codex review are addressed in the amended commit.
<wbr>to<br>;encrypted-exception-3$aabbcc$.odtgoes from 91 to 92 blank lines in a select-all copy with every empty paragraph still visible at unchanged height..odr-sheet>tbody>tr>td x-p), withheight:inheritleft child-scoped where it belongs. All 98 shape paragraphs in the corpus name their own font, so no output moved; verified against the emitted stylesheet with a synthetic cell instead — a cell paragraph and a shape paragraph naming no font both resolve to 10pt/13.333px, where the shape one had fallen back to the browser default.🤖 Generated with Claude Code