css_tweaks: add generic setting for smaller inpage footnotes (#13613)

Replaces the 3 '... (smaller)' tweaks.
This commit is contained in:
Benedikt McMullin
2025-06-01 20:03:24 +02:00
committed by GitHub
parent 521401c113
commit cfc67797e2
3 changed files with 91 additions and 99 deletions

View File

@@ -24,8 +24,9 @@ local T = require("ffi/util").template
-- Default globally enabled style tweaks, for new installations
local DEFAULT_GLOBAL_STYLE_TWEAKS = {}
-- Display in-page per-specs footnotes for EPUB and FB2:
DEFAULT_GLOBAL_STYLE_TWEAKS["footnote-inpage_epub_smaller"] = true
DEFAULT_GLOBAL_STYLE_TWEAKS["footnote-inpage_epub"] = true
DEFAULT_GLOBAL_STYLE_TWEAKS["footnote-inpage_fb2"] = true
DEFAULT_GLOBAL_STYLE_TWEAKS["inpage_footnote_font-size_smaller"] = true
local CssTweaks = {
DEFAULT_GLOBAL_STYLE_TWEAKS = DEFAULT_GLOBAL_STYLE_TWEAKS,
@@ -898,7 +899,7 @@ body[name="comments"] > section
{
id = "footnote-inpage_epub",
conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_") end,
global_conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_epub") end,
global_conflicts_with = false,
title = _("In-page EPUB footnotes"),
description = _([[
Show EPUB footnote text at the bottom of pages that contain links to them.
@@ -920,43 +921,10 @@ This only works with footnotes that have specific attributes set by the publishe
}
]],
},
{
id = "footnote-inpage_epub_smaller",
conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_") end,
global_conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_epub") end,
title = _("In-page EPUB footnotes (smaller)"),
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 non-FB2 documents, as FB2 can have <a type="note">
-- and we don't want to have them smaller
css = [[
*[type~="note"],
*[type~="endnote"],
*[type~="footnote"],
*[type~="rearnote"],
*[role~="doc-note"],
*[role~="doc-endnote"],
*[role~="doc-footnote"],
*[role~="doc-rearnote"]
{
-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;
}
]],
separator = true,
},
{
id = "footnote-inpage_wikipedia",
conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_") end,
global_conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_wikipedia") end,
global_conflicts_with = false,
title = _("In-page Wikipedia footnotes"),
description = _([[Show footnotes at the bottom of pages in Wikipedia EPUBs.]]),
css = [[
@@ -970,37 +938,13 @@ ol.references > li > .noprint { display: none; }
ol.references > li > .mw-cite-backlink { display: none; }
]],
},
{
id = "footnote-inpage_wikipedia_smaller",
conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_") end,
global_conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_wikipedia") end,
title = _("In-page Wikipedia footnotes (smaller)"),
description = _([[Show footnotes at the bottom of pages in Wikipedia EPUBs.]]),
css = [[
ol.references > li {
-cr-hint: footnote-inpage;
list-style-position: -cr-outside;
margin: 0 !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; }
ol.references > li > .mw-cite-backlink { display: none; }
]],
separator = true,
},
-- We can add other classic classnames to the 2 following
-- tweaks (except when named 'calibreN', as the N number is
-- We can add other classic classnames to the following
-- tweak (except when named 'calibreN', as the N number is
-- usually random across books).
{
id = "footnote-inpage_classic_classnames",
conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_") end,
global_conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_classic_classnames") end,
global_conflicts_with = false,
title = _("In-page classic classname footnotes"),
description = _([[
Show footnotes with classic classnames at the bottom of pages.
@@ -1016,32 +960,6 @@ This tweak can be duplicated as a user style tweak when books contain footnotes
{
-cr-hint: footnote-inpage;
margin: 0 !important;
}
]],
},
{
id = "footnote-inpage_classic_classnames_smaller",
conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_") end,
global_conflicts_with = function(id) return util.stringStartsWith(id, "footnote-inpage_classic_classnames") end,
title = _("In-page classic classname footnotes (smaller)"),
description = _([[
Show footnotes with classic classnames 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, .footnotes, .fn,
.note, .note1, .note2, .note3,
.ntb, .ntb-txt, .ntb-txt-j,
.przypis, .przypis1, /* Polish footnotes */
.voetnoten /* Dutch footnotes */
{
-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;
}
]],
separator = true,
@@ -1102,6 +1020,21 @@ This tweak can be duplicated as a user style tweak when a book contains other el
(function()
local sub_table = {
title = _("In-page footnote font size"),
{
id = "inpage_footnote_font-size_smaller",
conflicts_with = function(id) return util.stringStartsWith(id, "inpage_footnote_font-size_") end,
title = _("Smaller footnotes (80%, legacy)"),
description = _([[
Decrease size of in-page footnotes. This may have no effect if it's overwritten by publisher styles. The "footnote font size" style tweaks are recommended instead.]]),
css = [[
*, autoBoxing {
-cr-hint: late;
-cr-only-if: -fb2-document inpage-footnote;
font-size: 0.8rem !important;
}
]],
separator = true,
},
}
for __, rem in ipairs( { 1.0, 0.9, 0.85, 0.8, 0.75, 0.7, 0.65 } ) do
local pct = rem * 100