From a5232594d92d08e9c52aa18acc683464921457ea Mon Sep 17 00:00:00 2001 From: poire-z Date: Thu, 27 Feb 2020 12:12:53 +0100 Subject: [PATCH] FB2 footnotes: handle them just as other footnotes - FB2 footnotes are no more rendered in-page by default - In-page rendering can be enable by the added Style tweak - FB2 footnotes can also show in footnote popup (with some added not-so-nice CSS so MuPDF can render them as crengine) --- frontend/apps/reader/modules/readerlink.lua | 10 ++++++---- frontend/ui/data/css_tweaks.lua | 16 ++++++++++++++++ frontend/ui/widget/footnotewidget.lua | 15 +++++++++++++++ 3 files changed, 37 insertions(+), 4 deletions(-) diff --git a/frontend/apps/reader/modules/readerlink.lua b/frontend/apps/reader/modules/readerlink.lua index 7e3e5f8f0..26378f3b1 100644 --- a/frontend/apps/reader/modules/readerlink.lua +++ b/frontend/apps/reader/modules/readerlink.lua @@ -1000,13 +1000,15 @@ function ReaderLink:showAsFootnotePopup(link, neglect_current_location) -- if not trusted, checks marked (*) don't apply flags = flags + 0x0002 end + -- Checks for private CSS properties "-cr-hint: footnote/noteref/..." are + -- always done (they can be applied to specific elements or classe names + -- with Styles tweaks.) -- Trust role= and epub:type= attribute values if defined, for source(*) and target - -- (If needed, we could add a check for a private CSS property "-cr-hint: footnote" - -- or "-cr-hint: noteref", so one can define it to specific classes with Styles - -- tweaks.) flags = flags + 0x0004 - -- flags = flags + 0x0008 -- Unused yet + + -- Accept classic FB2 footnotes: body[name="notes" or "comments"] > section + flags = flags + 0x0008 -- TARGET STATUS AND SOURCE RELATION -- Target must have an anchor #id (ie: must not be a simple link to a html file) diff --git a/frontend/ui/data/css_tweaks.lua b/frontend/ui/data/css_tweaks.lua index 7f5190f11..b04542a8d 100644 --- a/frontend/ui/data/css_tweaks.lua +++ b/frontend/ui/data/css_tweaks.lua @@ -613,6 +613,22 @@ This is just an example, that will need to be adapted into a user style tweak.]] }, { title = _("In-page footnotes"), + { + id = "footnote-inpage_fb2"; + title = _("In-page FB2 footnotes"), + description = _([[ +Show FB2 footnote text at the bottom of pages that contain links to them.]]), + -- (fb2.css already set font-size to 70% - so no need for a "smaller" variant) + css = [[ +body[name="notes"] section, +body[name="comments"] section +{ + -cr-hint: footnote-inpage; + margin: 0 !important; +} + ]], + separator = true, + }, { id = "footnote-inpage_epub"; title = _("In-page EPUB footnotes"), diff --git a/frontend/ui/widget/footnotewidget.lua b/frontend/ui/widget/footnotewidget.lua index 179bf1a52..9e27e9f0d 100644 --- a/frontend/ui/widget/footnotewidget.lua +++ b/frontend/ui/widget/footnotewidget.lua @@ -89,6 +89,21 @@ body > li { list-style-type: none; } /* Remove any (possibly multiple) backlinks in Wikipedia EPUBs footnotes */ .noprint { display: none; } + +/* 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) */ +body > section > autoBoxing > *, +body > section > autoBoxing > title > *, +body > section > title, +body > section > title > p, +body > section > p { + display: inline; +} +body > section > autoBoxing + p, +body > section > p + p { + display: block; +} ]] -- Add this if needed for debugging: