Skip to content

Commit

Permalink
lint: Add t-076, grapheme or phoneme not italicized
Browse files Browse the repository at this point in the history
  • Loading branch information
acabal committed Oct 15, 2024
1 parent 2276813 commit 7597dee
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions se/se_epub_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
XHTML
Expand Down Expand Up @@ -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.", 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:
Expand Down
2 changes: 2 additions & 0 deletions tests/lint/typography/t-076/golden/t-076-out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
t-076 [Error] chapter-1.xhtml Grapheme or phoneme not italicized.
Two f’s.
19 changes: 19 additions & 0 deletions tests/lint/typography/t-076/in/src/epub/text/chapter-1.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" epub:prefix="z3998: http://www.daisy.org/z3998/2012/vocab/structure/, se: https://standardebooks.org/vocab/1.0" xml:lang="en-GB">
<head>
<title>I</title>
<link href="../css/core.css" rel="stylesheet" type="text/css"/>
<link href="../css/local.css" rel="stylesheet" type="text/css"/>
</head>
<body epub:type="bodymatter z3998:fiction">
<section id="chapter-1" epub:type="chapter">
<h2 epub:type="ordinal z3998:roman">I</h2>
<!-- Match -->
<p>Two f’s.</p>
<!-- Ignore uppercase -->
<p>The three R’s.</p>
<!-- Ignore common dialect -->
<p>“I’s hungry,” he said.</p>
</section>
</body>
</html>

0 comments on commit 7597dee

Please sign in to comment.