From f6dc474e61d021198ccb08d09ccc9b15885da2df Mon Sep 17 00:00:00 2001 From: aiongg <67543387+aiongg@users.noreply.github.com> Date: Thu, 8 Oct 2026 05:45:37 +0000 Subject: [PATCH] chore: count indentation-only property text as empty in compare.py InDesign writes some empty Properties children open and closed on two lines, so their text is a line feed and tabs (XMLImportPreference/Properties/TransformParameters). compare.py now treats such text as empty. measurement.md says so. Effect (measurement only, same output): P.TransformParameters reproduced in 489 of 489 trustworthy pairs. Trustworthy value coverage 97.12% -> 97.12% (+489 values); all pairs +654. --- docs/measurement.md | 2 +- tools/compare.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/measurement.md b/docs/measurement.md index d485f44..1ce48d8 100644 --- a/docs/measurement.md +++ b/docs/measurement.md @@ -120,7 +120,7 @@ A **value** is one of these, in the reference IDML: |---|---|---| | Element presence | Element with `Self`; the first child without `Self` of each tag, if it has attributes (counted as `Parent/Child`); in a child without attributes, its children with attributes (`Parent/Child/Grandchild`); each preference element | The output has an element with the same tag and `Self` (of the parent, for children) | | Attribute | Attribute other than `Self` | The output's attribute is equal, with numbers compared to 6 significant digits | -| `` child | Child of `Properties` (`P.Name`) | Equal text and attributes; a structured child (`PathGeometry`, lists) is compared as a whole | +| `` child | Child of `Properties` (`P.Name`) | Equal text and attributes; a structured child (`PathGeometry`, lists) is compared as a whole. Text that is only a line feed and tabs counts as empty: InDesign writes some empty elements open and closed on two lines (`XMLImportPreference/Properties/TransformParameters`) | | Story text | Story | The text, with paragraph breaks, is identical | | Text range | Start of a paragraph and character style range, at any depth inside wrappers, in the story's text or in a footnote, table cell or note (below) | The output has a range starting at the same offset of the same text flow | | Text range attribute | Attribute or `Properties` child of the range | Equal | diff --git a/tools/compare.py b/tools/compare.py index 4fbc1cd..ab822d8 100644 --- a/tools/compare.py +++ b/tools/compare.py @@ -399,6 +399,10 @@ def props(el): a["P." + c.tag] = canon(c) elif len(c) == 0: text = c.text or "" + # A line feed and tabs alone are the indentation of an + # element written open and closed (docs/measurement.md). + if re.fullmatch(r"\n\t*", text): + text = "" extra = sorted((k, v) for k, v in c.attrib.items() if k != "type") if extra: text = " ".join(f"{k}={v}" for k, v in extra)