From f8438f9496b1a55eb61bdb2c1827a66745293232 Mon Sep 17 00:00:00 2001 From: Gijs van Tulder Date: Fri, 6 Sep 2024 18:47:55 +0200 Subject: [PATCH] build: Keep vh/vw units in CSS, but add % as fallback. --- se/se_epub_build.py | 2 +- .../build/test-1/golden/extracted/epub/css/local.css | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/se/se_epub_build.py b/se/se_epub_build.py index dc503e3c..37a2ba92 100644 --- a/se/se_epub_build.py +++ b/se/se_epub_build.py @@ -561,7 +561,7 @@ def build(self, run_epubcheck: bool, check_only: bool, build_kobo: bool, build_k processed_css = regex.sub(r"(\s+)page-break-(before|after):\s+page;", "\\1page-break-\\2: always;", processed_css) # Replace `vw` or `vh` units with percent, a reasonable approximation - processed_css = regex.sub(r"([0-9\.]+\s*)v(w|h);", r"\1%;", processed_css) + processed_css = regex.sub(r"^(.+?:\s*[0-9\.]+\s*)(v(w|h));", r"\1%;\n\1\2;", processed_css, flags=regex.MULTILINE) if processed_css != css: file.seek(0) diff --git a/tests/ebook_commands/build/test-1/golden/extracted/epub/css/local.css b/tests/ebook_commands/build/test-1/golden/extracted/epub/css/local.css index f3b8470f..b3bc1fd2 100644 --- a/tests/ebook_commands/build/test-1/golden/extracted/epub/css/local.css +++ b/tests/ebook_commands/build/test-1/golden/extracted/epub/css/local.css @@ -3,17 +3,22 @@ figure.full-page{ max-height: 100%; + max-height: 100vh; } section.epub-type-preface{ margin-top: 20%; + margin-top: 20vh; } p{ margin-top: 20%; + margin-top: 20vh; margin-right: 10%; margin-bottom: 10px; margin-left: 10em; width: 5%; + width: 5vw; max-width: 12.5%; + max-width: 12.5vh; } \ No newline at end of file