Classify line ends by alignment clusters and canonicalize definition lists
The percentile-based right-margin estimate from the previous commit
misclassified two real-world layouts: at the column switch of the
two-column old-BGBl format a window contains both column margins, so the
90th percentile returned the right column's margin and marked every
left-column soft wrap as deliberate (vetoing hyphen mending, IfSG 2020:
"Impf- surveillance"); and series of equally wide centered "Artikel N"
headings in draft bills formed the top of their window's distribution,
so they counted as full-width and were reflowed into the following line,
breaking teileInArtikel's line anchor (ProdHaftG RegE). Classify against
alignment clusters instead: a line end is soft when at least five window
lines end within 4 pt of it (the justified block's own margin), hard when
such a cluster runs at least 10 pt above it, unclassified otherwise.
Structure anchors ("Artikel 2", "§ 19", bare Gliederung labels) are
always exempt from reflow since equal-width heading series still form
sham clusters. Also flush the pending line end-X at page ends — without
it, the first line of the next page inherited the previous page's footer
geometry and was misclassified (UWG: "Artikel 2" swallowed the closing
provisions).
Markerless joins additionally never cross into a following enumeration
marker line ("...vorgesehen und" + "d) die Überwachung" no longer glues
to "undd)"), a text-level veto that also works without geometry.
On the base-law side, ContentFlattener now separates sibling <LA>
elements within a <DD> — the short-label/definition pairs of the UWG
Anhang and § 2 IfSG were previously glued without any separator
("Irreführung über Unternehmereigenschaftdie unwahre Angabe...") in both
synopsis columns. The continuation line is indented two spaces deeper
than its enumeration line so StellenAufloeser.zeilenBlock keeps it inside
the unit's block ("Anhang Nummer 31 Buchstabe b"). BefehlAnwender writes
the same canonical shape when inserting or recasting quoted units
(rueckeZitatEin), so XML-derived and PDF-derived items agree:
" 2a. Stichwort" + " Definitionstext".
Verified by mvnw verify (179 tests, 7 new) and a before/after sweep of
all 21 sample law/amendment combinations: applied/manual counts are
unchanged throughout (UWG 19/0, GEG-BGBl 66/53, GModG-RegE 77/20,
IfSG-0645 42/24, ...), no marker characters leak into the HTML output.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Change-Id: Ib7faae1bc5c59bda83f648a579af16a4c77e4285
8 files changed