Repository navigation
Description
Why
#589 reports that an empty table cell is written as a TD > P whose marked-content sequence paints nothing. The same shape is written for every Layout element that holds text, and in a tagged document each one is a structure element a reader can land on and hear nothing from. The empty heading is the worst case: an H1 is a heading navigation stop. ISO 14289-1, 7.2 asks for "the most semantically appropriate tag" for each logical element, and an element with no content is not one; ISO 32000-1, 14.6.3 allows the empty marked-content sequence, so nothing is invalid.
Measured on origin/main b2791ba, saved under PDF/A-2a and PDF/UA-1, by reading each page's content stream and the structure tree (ConformanceAuditG3Tests.Iso14289_1_7_2_AnEmptyParagraphOrHeadingWritesAnEmptyElementWithAMarkedContentSequence, the empties fixture):
| input | structure written | the sequence paints |
|---|---|---|
new Paragraph("") |
P with MCID 0 |
nothing (no show operator) |
new Paragraph(" ") |
P with MCID 0 |
nothing |
new Heading("") |
H1 with MCID 1 |
nothing |
new ListItem([new TextRun("", style)]) |
LI > Lbl > P (the bullet) and LBody > P |
the bullet only |
NoteBlock.Add("") (a blank line) |
Div > P |
nothing |
new Preformatted("") |
P with MCID 0 |
nothing |
a Cell("") |
TD > P |
an empty Tj (#589) |
veraPDF 1.30.4 passes the empties file (paragraph, heading) under 2a and UA-1 in the audit's tests, and, run once by hand with the UA-1 claim saved, a file with the list item, the cell and the whitespace paragraph, and a file with the empty Preformatted. The blank note-block paragraph is in main-nolinks, which passes both. The note-block element is new in v2.4 (#721), which documents a paragraph with no text as "a blank line"; for the other rows the audit did not run 2.3.3, so it does not say whether they are older.
Sweep: git grep -n "BeginMarkedContent(" HEAD -- src on b2791ba finds seven callers: ParagraphRenderer (also the engine of Heading, ListItem and the paragraphs of a NoteBlock), PreformattedRenderer, TableRenderer (cells), LayoutImageRenderer, PieChartRenderer, BarcodeRenderer and the Kernel's own PdfCanvas. The first three write the element for empty text as the table shows. The image, chart and barcode callers draw a figure and were not probed with an empty input.
Proposal
Where the text of an element is empty or only white space, draw it as space (the element still takes its height) and write no marked-content sequence and no structure element for it, as #589 proposes for the cell; the label of a list item is its own text and keeps its element. Output changes only for inputs with no text, listed under "deliberate output changes".
Acceptance
- The skipped test
Iso14289_1_7_2_AnEmptyParagraphOrHeadingWritesNoStructureElementruns and passes, and its fixture adds the list item and the blank note-block paragraph. - A document with no empty text saves to the bytes of today.
- A
Preformattedof the empty string, which writes the emptyPabove, follows the same rule.
Activity
test: fix the second review of the structure and artifact audit
test: pin structure and artifact output to its ISO clauses (#761)