diff --git a/se/se_epub_lint.py b/se/se_epub_lint.py index 6f76d14c..ad126b80 100644 --- a/se/se_epub_lint.py +++ b/se/se_epub_lint.py @@ -2325,15 +2325,15 @@ def _lint_xhtml_typography_checks(filename: Path, dom: se.easy_xml.EasyXmlTree, node.remove() nodes = dom_copy.xpath("/html/body//p[re:test(., '[^=]\\s[0-9]{1,2}\\.[0-9]{2}(?![0-9′″°%]|\\.[0-9]|\\scubic|\\smetric|\\smeters|\\smiles|\\sfeet|\\sinches)')]") - matches = [] + matches = set() for node in nodes: for time_match in regex.findall(r"(?<=[^=]\s)[0-9]{1,2}\.[0-9]{2}(?![0-9′″°%]|\.[0-9]|\scubic|\smetric|\smeters|\smiles|\sfeet|\sinches)", node.inner_text()): time = time_match.split(".") if not time[0].startswith("0") and int(time[0]) >= 1 and int(time[0]) <= 12 and int(time[1]) >= 0 and int(time[1]) <= 59: - matches.append(time_match) + matches.add(time_match) if matches: - messages.append(LintMessage("t-010", "Time set with [text].[/] instead of [text]:[/].", se.MESSAGE_TYPE_WARNING, filename, set(matches))) + messages.append(LintMessage("t-010", "Time set with [text].[/] instead of [text]:[/].", se.MESSAGE_TYPE_WARNING, filename, natsorted(list(matches)))) # Check for missing punctuation before closing quotes # Exclude signatures in footers as those are commonly quoted without ending punctuation diff --git a/tests/lint/typography/t-010/golden/t-010-out.txt b/tests/lint/typography/t-010/golden/t-010-out.txt new file mode 100644 index 00000000..a1b5e736 --- /dev/null +++ b/tests/lint/typography/t-010/golden/t-010-out.txt @@ -0,0 +1,3 @@ +t-010 [Manual Review] chapter-1.xhtml Time set with `.` instead of `:`. + 1.00 + 12.59 diff --git a/tests/lint/typography/t-010/in/src/epub/text/chapter-1.xhtml b/tests/lint/typography/t-010/in/src/epub/text/chapter-1.xhtml new file mode 100644 index 00000000..3b59476f --- /dev/null +++ b/tests/lint/typography/t-010/in/src/epub/text/chapter-1.xhtml @@ -0,0 +1,45 @@ + + + + I + + + + +
+

I

+ +

It is 1.00.

+

It is 12.59.

+ + + +

It is 1:00.

+ +

It is 02.00.

+ +

X = 3.00.

+ +

It is 13.00.

+ +

It cost $12.00.

+ +

It is 4.001.

+ +

It is 4.60.

+ +

It is 4.01 cubic.

+

It is 4.01 metric.

+

It is 4.01 meters.

+

It is 4.01 miles.

+

It is 4.01 feet.

+

It is 4.01 inches.

+

It is 4.01′.

+

It is 4.01″.

+

It is 4.01°.

+

It is 4.01%.

+ +

See section 4.02.

+
+ +