From 34e6f41e05e199a0dfe76bdbb3126760516cdab0 Mon Sep 17 00:00:00 2001 From: poire-z Date: Sat, 18 May 2019 01:29:51 +0200 Subject: [PATCH] cre: fix 2 footnotes issues, bump crengine (#5031) - Popup footnotes: workaround strange behaviour of MuPDF which is adding some unwanted margin above elements with an "id=" attribute. - In-page footnotes: also remove any left and right margin, to keep footnotes aligned with the main text. Also add 2 classnames (witnessed in quite a few recent french books) to the list of classic classnames. - Also bump crengine: CSS: fix parsing of multi classnames and attributes selectors --- base | 2 +- frontend/ui/data/css_tweaks.lua | 22 ++++++++-------------- frontend/ui/widget/footnotewidget.lua | 5 +++++ 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/base b/base index 6b6497871..60e47ac54 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 6b6497871ba269e25ac9b2be69e1c77a106ac4d8 +Subproject commit 60e47ac54e69a8503306654a55edc16f43214577 diff --git a/frontend/ui/data/css_tweaks.lua b/frontend/ui/data/css_tweaks.lua index 08c4eca45..48ee03dd2 100644 --- a/frontend/ui/data/css_tweaks.lua +++ b/frontend/ui/data/css_tweaks.lua @@ -419,8 +419,7 @@ This only works with footnotes that have specific attributes set by the publishe *[role~="doc-rearnote"] { -cr-hint: footnote-inpage; - margin-top: 0 !important; - margin-bottom: 0 !important; + margin: 0 !important; } ]], }, @@ -439,8 +438,7 @@ This only works with footnotes that have specific attributes set by the publishe *[role~="doc-rearnote"] { -cr-hint: footnote-inpage; - margin-top: 0 !important; - margin-bottom: 0 !important; + margin: 0 !important; font-size: 80% !important; } ]], @@ -453,8 +451,7 @@ This only works with footnotes that have specific attributes set by the publishe css = [[ ol.references > li { -cr-hint: footnote-inpage; - margin-top: 0 !important; - margin-bottom: 0 !important; + margin: 0 !important; } /* hide backlinks */ ol.references > li > .noprint { display: none; } @@ -468,8 +465,7 @@ ol.references > li > .mw-cite-backlink { display: none; } css = [[ ol.references > li { -cr-hint: footnote-inpage; - margin-top: 0 !important; - margin-bottom: 0 !important; + margin: 0 !important; font-size: 80% !important; } /* hide backlinks */ @@ -488,11 +484,10 @@ ol.references > li > .mw-cite-backlink { display: none; } Show footnotes with classic class names at the bottom of pages. This tweak can be duplicated as a user style tweak when books contain footnotes wrapped with other class names.]]), css = [[ -.footnote, .note, .note1, .ntb +.footnote, .note, .note1, .ntb, .ntb-txt, .ntb-txt-j { -cr-hint: footnote-inpage; - margin-top: 0 !important; - margin-bottom: 0 !important; + margin: 0 !important; } ]], }, @@ -503,11 +498,10 @@ This tweak can be duplicated as a user style tweak when books contain footnotes Show footnotes with classic classname at the bottom of pages. This tweak can be duplicated as a user style tweak when books contain footnotes wrapped with other class names.]]), css = [[ -.footnote, .note, .note1, .ntb +.footnote, .note, .note1, .ntb, .ntb-txt, .ntb-txt-j { -cr-hint: footnote-inpage; - margin-top: 0 !important; - margin-bottom: 0 !important; + margin: 0 !important; font-size: 80% !important; } ]], diff --git a/frontend/ui/widget/footnotewidget.lua b/frontend/ui/widget/footnotewidget.lua index 52135c402..00086d0b8 100644 --- a/frontend/ui/widget/footnotewidget.lua +++ b/frontend/ui/widget/footnotewidget.lua @@ -174,6 +174,11 @@ function FootnoteWidget:init() --
abc
def
: 3 lines, empty line in between -- Remove any attribute, let a
be a plain
self.html = self.html:gsub([[]*>]], [[
]]) + -- Elements with a id= attribute get a line above them (by some internal MuPDF + -- code, possibly generate_anchor() in html-layout.c). + -- Working around it with the following does not work: *[id] {margin-top: -1em;} + -- So, just rename the id= attribute, as we don't follow links in this popup. + self.html = self.html:gsub([[(<[^>]* )[iI][dD]=]], [[%1disabledID=]]) -- We may use a font size a bit smaller than the document one (because -- footnotes are usually smaller, and because NotoSans is a bit on the