From 35d971c7dfa93823fd96ba0ff68cceabfc239ae1 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Mon, 14 Oct 2024 21:43:25 -0500 Subject: [PATCH] lint: Add t-076, grapheme or phoneme not italicized --- se/se_epub_lint.py | 6 ++++++ .../typography/t-076/golden/t-076-out.txt | 3 +++ .../t-076/in/src/epub/text/chapter-1.xhtml | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 tests/lint/typography/t-076/golden/t-076-out.txt create mode 100644 tests/lint/typography/t-076/in/src/epub/text/chapter-1.xhtml diff --git a/se/se_epub_lint.py b/se/se_epub_lint.py index 4f535c8b..2cea0e3a 100644 --- a/se/se_epub_lint.py +++ b/se/se_epub_lint.py @@ -431,6 +431,7 @@ "t-073", "Possible transcription error in Greek." "t-074", "Extended sound using hyphen-minus [text]-[/] instead of non-breaking hyphen [text]‑[/]." "t-075", "Word in verse with acute accent for scansion instead of grave accent." +"t-076", "Grapheme or phoneme not italicized. Hint: Dialect with missing letters should mark missing letters with [text]’[/]." XHTML @@ -2792,6 +2793,11 @@ def _lint_xhtml_typography_checks(filename: Path, dom: se.easy_xml.EasyXmlTree, if filtered_nodes: messages.append(LintMessage("t-075", "Word in verse with acute accent for scansion instead of grave accent.", se.MESSAGE_TYPE_WARNING, filename, [node.to_string() for node in filtered_nodes])) + # Check for graphemes or phonemes that are not italicized. + nodes = dom.xpath("/html/body//text()[re:test(., '\\s[a-z]’s\\b')]") + if nodes: + messages.append(LintMessage("t-076", "Grapheme or phoneme not italicized. Hint: Dialect with missing letters should mark missing letters with [text]’[/].", se.MESSAGE_TYPE_ERROR, filename, nodes)) + return (messages, missing_files) def _lint_xhtml_xhtml_checks(filename: Path, dom: se.easy_xml.EasyXmlTree, file_contents: str, local_css_path: str) -> list: diff --git a/tests/lint/typography/t-076/golden/t-076-out.txt b/tests/lint/typography/t-076/golden/t-076-out.txt new file mode 100644 index 00000000..624ef742 --- /dev/null +++ b/tests/lint/typography/t-076/golden/t-076-out.txt @@ -0,0 +1,3 @@ +t-076 [Error] chapter-1.xhtml Grapheme or phoneme not italicized. Hint: Dialect +with missing letters should mark missing letters with `’`. + Two f’s. diff --git a/tests/lint/typography/t-076/in/src/epub/text/chapter-1.xhtml b/tests/lint/typography/t-076/in/src/epub/text/chapter-1.xhtml new file mode 100644 index 00000000..7397bf6c --- /dev/null +++ b/tests/lint/typography/t-076/in/src/epub/text/chapter-1.xhtml @@ -0,0 +1,19 @@ + + + + I + + + + +
+

I

+ +

Two f’s.

+ +

The three R’s.

+ +

“I’s hungry,” he said.

+
+ +