diff --git a/frontend/apps/reader/modules/readerstyletweak.lua b/frontend/apps/reader/modules/readerstyletweak.lua index 98d7491f5..f7b0e28bb 100644 --- a/frontend/apps/reader/modules/readerstyletweak.lua +++ b/frontend/apps/reader/modules/readerstyletweak.lua @@ -879,6 +879,7 @@ You can then paste it here with long-press in the text box.]]), true}, { _("Private CSS properties"), { { "-cr-hint: footnote-inpage;", _("When set on a block element containing the target id of a href, this block element will be shown as an in-page footnote.")}, + { "-cr-hint: extend-footnote-inpage;", _("When set on a block element following a block element marked `footnote-inpage`, this block will be shown as part of the same in-page footnote as the previous element. Can be chained across multiple elements following an in-page footnote.")}, { "-cr-hint: non-linear;", _("Can be set on some specific DocFragments (e.g. DocFragment[id$=_16]) to ignore them in the linear pages flow.")}, { "-cr-hint: non-linear-combining;", _("Can be set on contiguous footnote blocks to ignore them in the linear pages flow.")}, { "-cr-hint: toc-level1;", _("When set on an element, its text can be used to build the alternative table of contents. toc-level2 to toc-level6 can be used for nested chapters.")}, diff --git a/frontend/ui/data/css_tweaks.lua b/frontend/ui/data/css_tweaks.lua index bd4daba60..22e1edaf5 100644 --- a/frontend/ui/data/css_tweaks.lua +++ b/frontend/ui/data/css_tweaks.lua @@ -943,6 +943,11 @@ This only works with footnotes that have specific attributes set by the publishe -cr-only-if: -fb2-document; -cr-hint: footnote-inpage; margin: 0 !important; +} +/* Also applies to extended footnotes */ +*, autoBoxing { + -cr-hint: late; + -cr-only-if: inpage-footnote; font-size: 0.8rem !important; } ]], @@ -976,7 +981,12 @@ ol.references > li { -cr-hint: footnote-inpage; list-style-position: -cr-outside; margin: 0 !important; - font-size: 0.8rem !important; +} +/* Also applies to extended footnotes */ +*, autoBoxing { + -cr-hint: late; + -cr-only-if: inpage-footnote; + font-size: 0.8rem !important; } /* hide backlinks */ ol.references > li > .noprint { display: none; } @@ -1026,11 +1036,58 @@ This tweak can be duplicated as a user style tweak when books contain footnotes { -cr-hint: footnote-inpage; margin: 0 !important; - font-size: 0.8rem !important; +} +/* Also applies to extended footnotes */ +*, autoBoxing { + -cr-hint: late; + -cr-only-if: inpage-footnote; + font-size: 0.8rem !important; } ]], separator = true, }, + { + title = _("In-page footnote extension"), + { + id = "extend-footnote-inpage_any", + conflicts_with = function(id) return util.stringStartsWith(id, "extend-footnote-inpage_") end, + title = _("Extend footnote content until next entry"), + description = _([[ +Extend in-page footnotes shown at the bottom of pages to include text up to the next footnote. +This might be needed when books don't correctly mark all text that belongs to the footnote.]]), +-- :where() and priority are needed to ensure lower specificity than +-- any other tweaks that check -cr-only-if: (inside-)inpage-footnote + priority = -1, + css = [[ +:where(*, autoBoxing) { + -cr-hint: late; + -cr-only-if: following-inpage-footnote -inpage-footnote; + -cr-hint: extend-footnote-inpage; + margin: 0 !important; +} + ]], + }, + { + id = "extend-footnote-inpage_until_heading", + conflicts_with = function(id) return util.stringStartsWith(id, "extend-footnote-inpage_") end, + title = _("Extend footnote content until next header"), + description = _([[ +Extend in-page footnotes shown at the bottom of pages to include text up to the next footnote or heading. +This might be needed when books don't correctly mark all text that belongs to the footnote. +This tweak can be duplicated as a user style tweak when a book contains other elements between footnotes that should not be shown in-page.]]), +-- :where() and priority are needed to ensure lower specificity than +-- any other tweaks that check -cr-only-if: (inside-)inpage-footnote + priority = -1, + css = [[ +:where(*:not(h1, h2, h3, h4, h5, h6), autoBoxing) { + -cr-hint: late; + -cr-only-if: following-inpage-footnote -inpage-footnote; + -cr-hint: extend-footnote-inpage; + margin: 0 !important; +} + ]], + }, + }, -- Next tweaks, with the help of crengine, will apply only to elements that were -- matched by previous tweaks that have set them the "footnote-inpage" cr-hint, -- and their children (their content).