mirror of
https://github.com/storytold/indd-utils.git
synced 2026-11-20 17:20:49 +01:00
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.
This commit is contained in:
1 parent
78b59b6319
commit
f6dc474e61
2 files changed
+5
-1
No files matched your search
+1
-1
@@ -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 |
|
||||
| `<Properties>` child | Child of `Properties` (`P.Name`) | Equal text and attributes; a structured child (`PathGeometry`, lists) is compared as a whole |
|
||||
| `<Properties>` 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 |
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user