From f0c6fc92dbeb7039dc647e174f33c828eba1d7c3 Mon Sep 17 00:00:00 2001 From: poire-z Date: Fri, 14 Feb 2020 08:22:27 +0100 Subject: [PATCH] Style tweaks: reorganize in submenus, add a few Try to limit the nb of items per menu page to 5 or 6 by splitting related ones into sub-menus, so we get more room below to see how they affect the content. Adds "No indentation on first/following paragraphs" and "Paragraphs margins and paddings", and Links underlining. --- frontend/ui/data/css_tweaks.lua | 293 ++++++++++++++++++++------------ 1 file changed, 180 insertions(+), 113 deletions(-) diff --git a/frontend/ui/data/css_tweaks.lua b/frontend/ui/data/css_tweaks.lua index 03823d248..600bb882e 100644 --- a/frontend/ui/data/css_tweaks.lua +++ b/frontend/ui/data/css_tweaks.lua @@ -34,6 +34,7 @@ local CssTweaks = { title = _("Ignore vertical margins"), priority = 2, css = [[* { margin-top: 0 !important; margin-bottom: 0 !important; }]], + separator = true, }, { id = "padding_horizontal_all_0"; @@ -50,78 +51,81 @@ local CssTweaks = { separator = true, }, { - id = "titles_page-break-before_avoid "; - title = _("Avoid blank page on chapter start"), - priority = 2, -- so it can override the one put back by publisher_page-break-before_avoid - css = [[h1, h2, h3 { page-break-before: auto !important; }]], + title = _("Page breaks and blank pages"), + { + id = "titles_page-break-before_avoid "; + title = _("Avoid blank page on chapter start"), + priority = 2, -- so it can override the one put back by publisher_page-break-before_avoid + css = [[h1, h2, h3 { page-break-before: auto !important; }]], - }, - { - id = "docfragment_page-break-before_avoid "; - title = _("Avoid blank page on chapter end"), - priority = 2, -- so it can override the one put back by publisher_page-break-before_avoid - css = [[DocFragment { page-break-before: auto !important; }]], - }, - { - id = "publisher_page-breaks_avoid "; - title = _("Avoid publisher page breaks"), - description = _("Disable all publisher page breaks, keeping only KOReader's epub.css ones.\nWhen combined with the two previous tweaks, all page-breaks are disabled."), - css = [[ + }, + { + id = "docfragment_page-break-before_avoid "; + title = _("Avoid blank page on chapter end"), + priority = 2, -- so it can override the one put back by publisher_page-break-before_avoid + css = [[DocFragment { page-break-before: auto !important; }]], + }, + { + id = "publisher_page-breaks_avoid "; + title = _("Avoid publisher page breaks"), + description = _("Disable all publisher page breaks, keeping only KOReader's epub.css ones.\nWhen combined with the two previous tweaks, all page-breaks are disabled."), + css = [[ * { page-break-before: auto !important; page-break-after: auto !important; } /* put back epub.css page-breaks */ DocFragment { page-break-before: always !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; }]], + ]], + separator = true, }, { - id = "h2_page-break-before_always"; - title = _("New page on

"), - css = [[ + 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 = [[ + ]], + }, + { + 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 = [[ + ]], + }, + { + 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 = [[ + ]], + }, + { + 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 = [[ + ]], + }, + { + 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; } - ]], + ]], + }, }, }, }, @@ -204,6 +208,7 @@ You may also want to enable, in the top menu → Gear → Navigation →, Invert title = _("Document direction LTR"), css = [[body { direction: ltr !important; }]], }, + separator = true, }, { title = _("Widows and orphans"), @@ -279,43 +284,47 @@ h1, h2, h3, h4, h5, h6 { hyphens: none !important; } separator = true, }, { - id = "sub_sup_smaller"; - title = _("Smaller sub- and superscript"), - description = _("Prevent sub- and superscript from affecting line-height."), - priority = 5, -- so we can override "font_size_all_inherit" - -- https://friendsofepub.github.io/eBookTricks/ - -- https://github.com/koreader/koreader/issues/3923#issuecomment-386510294 - css = [[ + title = _("Fonts and line heights"), + { + id = "font_family_all_inherit"; + title = _("Ignore publisher font families"), + description = _("Disable font-family specified in embedded styles."), + -- we have to use this trick, font-family handling by crengine is a bit complex + css = [[* { font-family: "NoSuchFont" !important; }]], + }, + { + id = "font_size_all_inherit"; + title = _("Ignore publisher font sizes"), + description = _("Disable font-size specified in embedded styles."), + css = [[* { font-size: inherit !important; }]], + separator = true, + }, + { + id = "lineheight_all_inherit"; + title = _("Ignore publisher line heights"), + description = _("Disable line-height specified in embedded styles, and may allow KOReader's line spacing settings to work on books where they would not."), + css = [[* { line-height: inherit !important; }]], + }, + { + id = "lineheight_all_normal_strut_confined"; + title = _("Enforce steady line heights"), + description = _("Prevent inline content like sub- and superscript from changing their paragraph line height."), + priority = -5, -- so other -cr-hint can override (this one has effect only on inline content) + css = [[* { -cr-hint: strut-confined; }]], + separator = true, + }, + { + id = "sub_sup_smaller"; + title = _("Smaller sub- and superscript"), + description = _("Prevent sub- and superscript from affecting line-height."), + priority = 5, -- so we can override "font_size_all_inherit" + -- https://friendsofepub.github.io/eBookTricks/ + -- https://github.com/koreader/koreader/issues/3923#issuecomment-386510294 + css = [[ sup { font-size: 50% !important; vertical-align: super !important; } sub { font-size: 50% !important; vertical-align: sub !important; } - ]], - }, - { - id = "lineheight_all_inherit"; - title = _("Ignore publisher line heights"), - description = _("Disable line-height specified in embedded styles, and may allow KOReader's line spacing settings to work on books where they would not."), - css = [[* { line-height: inherit !important; }]], - }, - { - id = "lineheight_all_normal_strut_confined"; - title = _("Enforce steady line heights"), - description = _("Prevent inline content like sub- and superscript from changing their paragraph line height."), - priority = -5, -- so other -cr-hint can override (this one has effect only on inline content) - css = [[* { -cr-hint: strut-confined; }]], - separator = true, - }, - { - id = "font_size_all_inherit"; - title = _("Ignore publisher font sizes"), - description = _("Disable font-size specified in embedded styles."), - css = [[* { font-size: inherit !important; }]], - }, - { - id = "font_family_all_inherit"; - title = _("Ignore publisher font families"), - description = _("Disable font-family specified in embedded styles."), - -- we have to use this trick, font-family handling by crengine is a bit complex - css = [[* { font-family: "NoSuchFont" !important; }]], + ]], + }, }, }, { @@ -338,38 +347,83 @@ p { separator = true, }, { - id = "paragraph_no_indent"; - title = _("No indentation on first paragraph line"), - description = _("Do not indent the first line of paragraphs."), - css = [[p { text-indent: 0 !important; }]], - }, - { - id = "paragraph_indent"; - title = _("Indentation on first paragraph line"), - description = _("Indentation on the first line of a paragraph is the default, but it may be overridden by publisher styles. This will force KOReader's defaults on common elements."), - css = [[ + title = _("Paragraph first-line indentation"), + { + id = "paragraph_no_indent"; + title = _("No indentation on first paragraph line"), + description = _("Do not indent the first line of paragraphs."), + css = [[p { text-indent: 0 !important; }]], + separator = true, + }, + { + id = "paragraph_indent"; + title = _("Indentation on first paragraph line"), + description = _("Indentation on the first line of a paragraph is the default, but it may be overridden by publisher styles. This will force KOReader's defaults on common elements."), + css = [[ p { text-indent: 1.2em !important; } body, h1, h2, h3, h4, h5, h6, div, li, td, th { text-indent: 0 !important; } - ]], - separator = true, + ]], + }, + { + id = "paragraph_first_no_indent"; + title = _("No indentation on first paragraph"), + description = _("Do not indent the first line of the first paragraph of its container. This might be needed to correctly display drop caps, while still having indentation on following paragraphs."), + priority = 2, -- so it can override 'paragraph_indent' + css = [[p:first-child { text-indent: 0 !important; }]], + }, + { + id = "paragraph_following_no_indent"; + title = _("No indentation on following paragraphs"), + description = _("Do not indent the first line of following paragraphs, but leave the first paragraph of its container untouched."), + priority = 2, -- so it can override 'paragraph_indent' + css = [[p + p { text-indent: 0 !important; }]], + }, }, { - id = "paragraph_whitespace"; title = _("Spacing between paragraphs"), - description = _("Add a line of whitespace between paragraphs."), - css = [[p + p { margin-top: 1em !important; }]], - }, - { - id = "paragraph_whitespace_half"; - title = _("Spacing between paragraphs (half)"), - description = _("Add half a line of whitespace between paragraphs."), - css = [[p + p { margin-top: .5em !important; }]], + { + id = "paragraph_whitespace"; + title = _("Spacing between paragraphs"), + description = _("Add a line of whitespace between paragraphs."), + priority = 5, -- Override "Ignore margins and paddings" below + css = [[p + p { margin-top: 1em !important; }]], + }, + { + id = "paragraph_whitespace_half"; + title = _("Spacing between paragraphs (half)"), + description = _("Add half a line of whitespace between paragraphs."), + priority = 5, + css = [[p + p { margin-top: .5em !important; }]], + }, + { + id = "paragraph_no_whitespace"; + title = _("No spacing between paragraphs"), + description = _("No whitespace between paragraphs is the default, but it may be overridden by publisher styles. This will re-enable it for paragraphs and list items."), + priority = 5, + css = [[p, li { margin-top: 0 !important; margin-bottom: 0 !important; }]], + separator = true, + }, + { + id = "paragraph_no_vertical_padding"; + title = _("Ignore vertical paragraph padding"), + priority = 3, -- Override "Pages > Ignore margin and padding" + css = [[p, li { padding-top: 0 !important; padding-bottom: 0 !important; }]], + }, }, { - id = "paragraph_no_whitespace"; - title = _("No spacing between paragraphs"), - description = _("No whitespace between paragraphs is the default, but it may be overridden by publisher styles. This will re-enable it for paragraphs and list items."), - css = [[p, li { margin-top: 0 !important; margin-bottom: 0 !important; }]], + title = _("Horizontal paragraph margins"), + { + id = "paragraph_no_horizontal_margin"; + title = _("Ignore horizontal paragraph margins"), + priority = 3, -- Override "Pages > Ignore margin and padding" + css = [[p, li { margin-left: 0 !important; margin-right: 0 !important; }]], + }, + { + id = "paragraph_no_horizontal_padding"; + title = _("Ignore horizontal paragraph padding"), + priority = 3, + css = [[p, li { padding-left: 0 !important; padding-right: 0 !important; }]], + }, }, }, { @@ -391,6 +445,7 @@ body, h1, h2, h3, h4, h5, h6, div, li, td, th { text-indent: 0 !important; } title = _("Center small tables"), description = _("Horizontally center tables that do not use the full page width."), css = [[table { margin-left: auto !important; margin-right: auto !important; }]], + priority = 3, -- Override "Pages > Ignore margin and padding" separator = true, }, { @@ -438,6 +493,18 @@ table, tcaption, tr, th, td { border: black solid 1px; border-collapse: collapse id = "a_not_bold"; title = _("Links never bold"), css = [[a { font-weight: normal !important; }]], + separator = true, + }, + { + id = "a_underline"; + title = _("Links always underlined"), + css = [[a[href] { text-decoration: underline !important; }]], + -- Have it apply only on real links with a href=, not on anchors + }, + { + id = "a_not_underline"; + title = _("Links never underlined"), + css = [[a { text-decoration: none !important; }]], }, }, {