From aedc5a48061f43d01285a4bc1d633f1bcfba4b9d Mon Sep 17 00:00:00 2001 From: poire-z Date: Sun, 14 Jul 2019 22:21:27 +0200 Subject: [PATCH] Style tweaks: update for latest epub.css, added a few more - Updated "Avoid page break" tweaks to work on our latest epub.css. - Added "New page on headings>" menu, as we no more break page on H1, H2, H3 in EPUBs. - Added "Center headings" as we no more have them centered. - Added "Pure black and white" which can make some documents more readable. --- frontend/ui/data/css_tweaks.lua | 74 ++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/frontend/ui/data/css_tweaks.lua b/frontend/ui/data/css_tweaks.lua index 48ee03dd2..d4dcb7ce8 100644 --- a/frontend/ui/data/css_tweaks.lua +++ b/frontend/ui/data/css_tweaks.lua @@ -48,9 +48,59 @@ local CssTweaks = { * { page-break-before: auto !important; page-break-after: auto !important; } /* put back epub.css page-breaks */ DocFragment { page-break-before: always !important; } -h1, h2, h3 { page-break-before: always !important; page-break-after: avoid !important; } -h4, h5, h6 { page-break-after: avoid !important; } +h1 { -cr-only-if: -epub-document; page-break-before: always !important; } +h2, h3 { -cr-only-if: legacy -epub-document; page-break-before: always !important; } +h1, h2, h3, h4, h5, h6 { page-break-after: avoid !important; } ]], + separator = true, + }, + { + title = _("New page on headings"), + { + id = "h1_page-break-before_always"; + title = _("New page on

"), + css = [[h1 { page-break-before: always !important; }]], + }, + { + id = "h2_page-break-before_always"; + title = _("New page on

"), + css = [[ +h2 { page-break-before: always !important; } +h1 + h2 { page-break-before: avoid !important; } + ]], + }, + { + id = "h3_page-break-before_always"; + title = _("New page on

"), + css = [[ +h3 { page-break-before: always !important; } +h1 + h3, h2 + h3 { page-break-before: avoid !important; } + ]], + }, + { + id = "h4_page-break-before_always"; + title = _("New page on

"), + css = [[ +h4 { page-break-before: always !important; } +h1 + h4, h2 + h4, h3 + h4 { page-break-before: avoid !important; } + ]], + }, + { + id = "h5_page-break-before_always"; + title = _("New page on

"), + css = [[ +h5 { page-break-before: always !important; } +h1 + h5, h2 + h5, h3 + h5, h4 + h5 { page-break-before: avoid !important; } + ]], + }, + { + id = "h6_page-break-before_always"; + title = _("New page on
"), + css = [[ +h6 { page-break-before: always !important; } +h1 + h6, h2 + h6, h3 + h6, h4 + h6, h5 + h6 { page-break-before: avoid !important; } + ]], + }, }, }, { @@ -83,6 +133,13 @@ h4, h5, h6 { page-break-after: avoid !important; } title = _("Justify all elements"), description = _("Text justification is the default, but it may be overridden by publisher styles. This will re-enable it for all elements, which may lose centering in some of them."), css = [[* { text-align: justify !important; }]], + separator = true, + }, + { + id = "headings_align_center", + title = _("Center headings"), + css = [[h1, h2, h3, h4, h5, h6 { text-align: center !important; }]], + priority = 3, -- so it overrides the ones above }, }, { @@ -521,6 +578,19 @@ switch > case { display: inline; } switch > default { display: none; } ]], }, + { + id = "pure_black_and_white"; + title = _("Pure black and white"), + description = _([[Enforce black text and borders, and remove backgrounds.]]), + css = [[ +* { + color: black !important; + border-color: black !important; + background-color: transparent !important; + background-image: !important; +} + ]], -- (This last empty background-image: works for cancelling any previous one + }, }, -- No current need for workarounds -- {