Skip to content

Commit

Permalink
build: Improve proofreading CSS, and add color to no-break spaces and…
Browse files Browse the repository at this point in the history
… no-break hyphens
  • Loading branch information
acabal committed Nov 5, 2024
1 parent 570a9ac commit 393b6e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 3 additions & 1 deletion se/data/templates/proofreading.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
[epub|type~="z3998:roman"],
[lang]:not(html),
abbr,
time{
time,
.proofreading,
span[epub|type]{
background: #C0C0C0;
}
10 changes: 10 additions & 0 deletions se/se_epub_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ def build(self, run_epubcheck: bool, check_only: bool, build_kobo: bool, build_k
with importlib.resources.files("se.data.templates").joinpath("proofreading.css").open("r", encoding="utf-8") as proofreading_css_file:
local_css_file.write("\n" + proofreading_css_file.read())

# Wrap no-break hyphens and no-break spaces in a class that will colorize them when proofing.
for file_path in work_compatible_epub_dir.glob("**/*.xhtml"):
with open(file_path, "r+", encoding="utf-8") as file:
xhtml = file.read()

xhtml = regex.sub(fr"([{se.NO_BREAK_HYPHEN}{se.NO_BREAK_SPACE}])", r"""<span class="proofreading">\1</span>""", xhtml)
file.seek(0)
file.write(se.formatting.simplify_css(xhtml))
file.truncate()

# Update the release date in the metadata and colophon
if self.last_commit:
for file_path in work_compatible_epub_dir.glob("**/*.xhtml"):
Expand Down

0 comments on commit 393b6e8

Please sign in to comment.