Skip to content

Commit

Permalink
lint: Improve t-064
Browse files Browse the repository at this point in the history
  • Loading branch information
acabal committed Jul 16, 2024
1 parent 3b5f53b commit 91a2cea
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions se/se_epub_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2703,9 +2703,8 @@ def _lint_xhtml_typography_checks(filename: Path, dom: se.easy_xml.EasyXmlTree,
# Ignore titles longer than 150 chars, as long titles are likely old-timey super-long titles that should be mostly sentence-cased
incorrectly_cased_titles = []
for node in dom.xpath("/html/body//*[contains(@epub:type, 'se:name') and not(contains(@epub:type, 'se:name.legal-case')) and not(@xml:lang) and not(./*) and string-length(.) <= 150]"):
# Replace any space that is not a hair space with a regular space. This is because in inline titles, we may correctly
# have nbsp for example after `St.`, but titlecase will remove that nbsp.
if se.formatting.titlecase(node.inner_text()) != regex.sub(fr"[^\S{se.HAIR_SPACE}]+", " ", node.inner_text()):
# Replace any space that is not a hair space or nbsp with a regular space.
if se.formatting.titlecase(node.inner_text()) != regex.sub(fr"[^\S{se.HAIR_SPACE}{se.NO_BREAK_SPACE}]+", " ", node.inner_text()):
incorrectly_cased_titles.append(node.to_string())

if incorrectly_cased_titles:
Expand Down

0 comments on commit 91a2cea

Please sign in to comment.