From 12c97cf0410a6781797ce7f9ebd3bfc16c087d06 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Wed, 6 Nov 2024 15:19:23 -0600 Subject: [PATCH] lint: Fix t-060 case where abbreviation is followed by a comma --- se/se_epub_lint.py | 2 +- tests/lint/typography/t-060/golden/t-060-out.txt | 3 +++ .../typography/t-060/in/src/epub/text/chapter-1.xhtml | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/se/se_epub_lint.py b/se/se_epub_lint.py index 1b6a73aa..61803c8a 100644 --- a/se/se_epub_lint.py +++ b/se/se_epub_lint.py @@ -2680,7 +2680,7 @@ def _lint_xhtml_typography_checks(filename: Path, dom: se.easy_xml.EasyXmlTree, messages.append(LintMessage("t-059", "Period at the end of [xhtml][/] element before endnote backlink.", se.MESSAGE_TYPE_WARNING, filename, [node.to_string() for node in nodes])) # Check for Bible verses in old-style notation - nodes = dom.xpath("/html/body//*[(name()='p' or name()='cite' or re:test(name(), '^h[1-6]$')) and .//node()[re:test(., '(Genesis|Gen\\.|Exodus|Ex\\.|Leviticus|Lev\\.|Numbers|Num\\.|Deuteronomy|Deut\\.|Joshua|Josh\\.|Judges|Ruth|Kings|Chronicles|Chron\\.|Ezra|Nehemiah|Neh\\.|Esther|Esth\\.|Job|Psalm|Psalms|Ps\\.|Proverbs|Prov\\.|Ecclesiastes|Ecc\\.|Eccl\\.|Solomon|Sol\\.|Isaiah|Is\\.|Isa\\.|Jeremiah|Jer\\.|Lamentations|Lam\\.|Ezekiel|Ez\\.|Ezek\\.|Daniel|Dan\\.|Hosea|Hos\\.|Joel|Amos|Obadiah|Obad\\.|Jonah|Jon\\.|Micah|Mic\\.|Nahum|Nah\\.|Habakkuk|Hab\\.|Zephaniah|Zeph\\.|Haggai|Hag\\.|Zechariah|Zech\\.|Malachi|Mal\\.|Tobit|Judith|Sirach|Baruch|Maccabees|Esdras|Manasses|Matthew|Matt\\.|Mark|Luke|John|Acts|Romans|Rom\\.|Corinthians|Cor\\.|Corinth\\.|Galatians|Gal\\.|Ephesians|Eph\\.|Philippians|Phil\\.|Philipp\\.|Colossians|Col\\.|Coloss\\.|Thessalonians|Thes\\.|Thess\\.|Timothy|Tim\\.|Titus|Tit\\.|Philemon|Phil\\.|Hebrews|Heb\\.|James|Jas\\.|Peter|Pet\\.|Jude|Revelation|Revelations|Rev\\.)(,?)\\s*$') and following-sibling::node()[normalize-space(.)][1][contains(@epub:type, 'z3998:roman') and following-sibling::node()[1][re:test(., '^\\s*[\\.,]?\\s+[0-9]')]]]]") + nodes = dom.xpath("/html/body//*[(name()='p' or name()='cite' or re:test(name(), '^h[1-6]$')) and .//node()[re:test(., '(Genesis|Gen\\.|Exodus|Ex\\.|Leviticus|Lev\\.|Numbers|Num\\.|Deuteronomy|Deut\\.|Joshua|Josh\\.|Judges|Ruth|Kings|Chronicles|Chron\\.|Ezra|Nehemiah|Neh\\.|Esther|Esth\\.|Job|Psalm|Psalms|Ps\\.|Proverbs|Prov\\.|Ecclesiastes|Ecc\\.|Eccl\\.|Solomon|Sol\\.|Isaiah|Is\\.|Isa\\.|Jeremiah|Jer\\.|Lamentations|Lam\\.|Ezekiel|Ez\\.|Ezek\\.|Daniel|Dan\\.|Hosea|Hos\\.|Joel|Amos|Obadiah|Obad\\.|Jonah|Jon\\.|Micah|Mic\\.|Nahum|Nah\\.|Habakkuk|Hab\\.|Zephaniah|Zeph\\.|Haggai|Hag\\.|Zechariah|Zech\\.|Malachi|Mal\\.|Tobit|Judith|Sirach|Baruch|Maccabees|Esdras|Manasses|Matthew|Matt\\.|Mark|Luke|John|Acts|Romans|Rom\\.|Corinthians|Cor\\.|Corinth\\.|Galatians|Gal\\.|Ephesians|Eph\\.|Philippians|Phil\\.|Philipp\\.|Colossians|Col\\.|Coloss\\.|Thessalonians|Thes\\.|Thess\\.|Timothy|Tim\\.|Titus|Tit\\.|Philemon|Phil\\.|Hebrews|Heb\\.|James|Jas\\.|Peter|Pet\\.|Jude|Revelation|Revelations|Rev\\.),?\\s*$') and following-sibling::node()[position() = 1 or position() = 2][contains(@epub:type, 'z3998:roman') and following-sibling::node()[1][re:test(., '^\\s*[\\.,]?\\s+[0-9]')]]]]") if nodes: messages.append(LintMessage("t-060", "Old style Bible citation.", se.MESSAGE_TYPE_WARNING, filename, [node.to_string() for node in nodes])) diff --git a/tests/lint/typography/t-060/golden/t-060-out.txt b/tests/lint/typography/t-060/golden/t-060-out.txt index cb566a85..1cd5accc 100644 --- a/tests/lint/typography/t-060/golden/t-060-out.txt +++ b/tests/lint/typography/t-060/golden/t-060-out.txt @@ -1,3 +1,6 @@ t-060 [Manual Review] chapter-1.xhtml Old style Bible citation. Genesis, i, 3 Genesis i, 3 + Gen., i, +3 +

Gen., i, 3

diff --git a/tests/lint/typography/t-060/in/src/epub/text/chapter-1.xhtml b/tests/lint/typography/t-060/in/src/epub/text/chapter-1.xhtml index 138200a5..1e3405ae 100644 --- a/tests/lint/typography/t-060/in/src/epub/text/chapter-1.xhtml +++ b/tests/lint/typography/t-060/in/src/epub/text/chapter-1.xhtml @@ -14,6 +14,16 @@

And God said, “Let there be light,” and there was light.

Genesis i, 3 + +
+

And God said, “Let there be light,” and there was light.

+ Gen., i, 3 +
+ +
+

And God said, “Let there be light,” and there was light.

+

Gen., i, 3

+

And God said, “Let there be light,” and there was light.