From cc653ef5b05999af5f0fb823bcf0ed7ed69b85b3 Mon Sep 17 00:00:00 2001 From: poire-z Date: Mon, 20 Jul 2020 13:12:07 +0200 Subject: [PATCH] Style tweaks: limit EPUB/FB2 footnotes to these formats Avoid conflicts having "In-page EPUB footnotes (smaller)" affects FB2 documents that use "12" which would then get smaller if both tweaks are enabled (which they are, by default). Also switch "-cr-hint: strut-confined" from being set on "*" to being set only on "body", now that it is inherited. Footnote popups: add styles for some non-HTML FB2 tags, so MuPDF can render them as expected. --- frontend/ui/data/css_tweaks.lua | 40 +++++++++++++++++---------- frontend/ui/widget/footnotewidget.lua | 5 ++++ 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/frontend/ui/data/css_tweaks.lua b/frontend/ui/data/css_tweaks.lua index 498f1a56e..9711b16b6 100644 --- a/frontend/ui/data/css_tweaks.lua +++ b/frontend/ui/data/css_tweaks.lua @@ -338,8 +338,8 @@ ruby { display: inline !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; }]], + -- strut-confined is among the few cr-hints that are inherited + css = [[body { -cr-hint: strut-confined; }]], separator = true, }, { @@ -650,13 +650,17 @@ This is just an example, that will need to be adapted into a user style tweak.]] title = _("In-page FB2 footnotes"), description = _([[ Show FB2 footnote text at the bottom of pages that contain links to them.]]), + -- Restrict this to FB2 documents, even if we won't probably + -- match in any other kind of document css = [[ body[name="notes"] section { - -cr-hint: footnote-inpage; - margin: 0 !important; + -cr-only-if: fb2-document; + -cr-hint: footnote-inpage; + margin: 0 !important; } body[name="notes"] > section { - font-size: 0.75rem; + -cr-only-if: fb2-document; + font-size: 0.75rem; } ]], }, @@ -667,11 +671,13 @@ body[name="notes"] > section { Show FB2 endnote text at the bottom of pages that contain links to them.]]), css = [[ body[name="comments"] section { - -cr-hint: footnote-inpage; - margin: 0 !important; + -cr-only-if: fb2-document; + -cr-hint: footnote-inpage; + margin: 0 !important; } body[name="comments"] > section { - font-size: 0.85rem; + -cr-only-if: fb2-document; + font-size: 0.85rem; } ]], separator = true, @@ -685,7 +691,8 @@ FB2 footnotes and endnotes get a smaller font size when displayed in-page. This body[name="notes"] > section, body[name="comments"] > section { - font-size: 1rem !important; + -cr-only-if: fb2-document; + font-size: 1rem !important; } ]], }, @@ -697,6 +704,7 @@ body[name="comments"] > section description = _([[ Show EPUB footnote text at the bottom of pages that contain links to them. This only works with footnotes that have specific attributes set by the publisher.]]), + -- Restrict this to EPUB documents, as FB2 can have css = [[ *[type~="note"], *[type~="footnote"], @@ -705,8 +713,9 @@ This only works with footnotes that have specific attributes set by the publishe *[role~="doc-footnote"], *[role~="doc-rearnote"] { - -cr-hint: footnote-inpage; - margin: 0 !important; + -cr-only-if: epub-document; + -cr-hint: footnote-inpage; + margin: 0 !important; } ]], }, @@ -716,6 +725,8 @@ This only works with footnotes that have specific attributes set by the publishe description = _([[ Show EPUB footnote text at the bottom of pages that contain links to them. This only works with footnotes that have specific attributes set by the publisher.]]), + -- Restrict this to EPUB documents, as FB2 can have + -- and we don't want to have them smaller css = [[ *[type~="note"], *[type~="footnote"], @@ -724,9 +735,10 @@ This only works with footnotes that have specific attributes set by the publishe *[role~="doc-footnote"], *[role~="doc-rearnote"] { - -cr-hint: footnote-inpage; - margin: 0 !important; - font-size: 0.8rem !important; + -cr-only-if: epub-document; + -cr-hint: footnote-inpage; + margin: 0 !important; + font-size: 0.8rem !important; } ]], separator = true, diff --git a/frontend/ui/widget/footnotewidget.lua b/frontend/ui/widget/footnotewidget.lua index 4d341461b..45623a90c 100644 --- a/frontend/ui/widget/footnotewidget.lua +++ b/frontend/ui/widget/footnotewidget.lua @@ -90,6 +90,11 @@ body > li { list-style-type: none; } /* Remove any (possibly multiple) backlinks in Wikipedia EPUBs footnotes */ .noprint { display: none; } +/* Style some FB2 tags not known to MuPDF */ +emphasis { font-style: italic; } +strikethrough { text-decoration: line-through; } +underline { text-decoration: underline; } + /* Attempt to display FB2 footnotes as expected (as crengine does, putting * the footnote number on the same line as the first paragraph via its * support of "display: run-in" and a possibly added autoBoxing element) */