Skip to content

style tweak: Extend inpage footnotes - #13554

Merged
poire-z merged 12 commits into
koreader:masterfrom
moben:extend-footnote-inpage
May 25, 2025
Merged

poire-z merged 12 commits into
koreader:masterfrom
moben:extend-footnote-inpage

Conversation

@moben

@moben moben commented Apr 10, 2025 •

Copy link
Copy Markdown
Contributor

Style tweak for koreader/crengine#618 to allow extending footnotes across lines from consecutive nodes.

Suggestions welcome where it should live. I'd argue it belongs top-level as it selects what gets shown as footnotes, just like the other tweaks there.

Depends on:


This change is Reviewable

Comment thread frontend/ui/data/css_tweaks.lua Outdated
Comment on lines +1043 to +1046
-cr-only-if: following-inpage-footnote -inpage-footnote;
-cr-hint: extend-footnote-inpage;
margin: 0 !important;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More indentation on the lines following a -cr-only-if: (to make it visually clear the next apply only-if :) ala python.
cf the existing ones.

@poire-z

poire-z commented Apr 11, 2025

Copy link
Copy Markdown
Contributor

Fine with the first - it's generic enough.
Not sure where to place it: in the top menu, as it tweaks the behaviour of the others above - but it's a bit technical and not obvious; or in the "fixup" submenu, but it's a bit unlike the others that just do visual tweaks.

Not fine with the second, it brings too much of the existing noisy classname ones.

If you feel they need to be mentionned somewhere so users know they exist, we can also mention them in the CSS ☰ popup button in the Book style tweak editor:

{ _("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: 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.")},
{ "-cr-hint: toc-ignore;", _("When set on an element, it will be ignored when building the alternative table of contents.")},

@moben
moben force-pushed the extend-footnote-inpage branch from d9abc15 to c73f0e4 Compare April 15, 2025 23:24
@moben moben changed the title demo style tweak: Extend inpage footnotes style tweak: Extend inpage footnotes Apr 15, 2025
@poire-z

poire-z commented Apr 15, 2025

Copy link
Copy Markdown
Contributor

If you add 2 items, we'll get 11 items, with one on the 2nd page (in landscape mode).
If you really need these 2 new ones, it feels best to create a submenu (so, 3 submenus at bottom), ie. "In-page footnote extension".

@moben

moben commented Apr 15, 2025

Copy link
Copy Markdown
Contributor Author

I'm fine with a submenu if you're willing to have multiple versions of this tweak. (and maybe someone comes up with another one in the future)

I do think having the two versions "until next footnote" (aka *, autoBoxing) and "until next heading or footnote" (aka *:not(h1,...), autoBoxing makes sense because the former is the maximalist version that makes sure you never miss any footnotes and the latter is close to what popup footnotes do so there's some precedent for this being a good stopping point (and I have at least one actual book where it's the correct choice).

Having a version with :not() as an example to copy from might also be nice for people who aren't css experts to have an easier time writing user / book tweaks.

@moben

moben commented Apr 16, 2025

Copy link
Copy Markdown
Contributor Author
  1. Moved footnote extension to submenu
  2. Fixed "smaller" variants of in-page footnotes in the presence of extended footnotes.

I think the fix for (2) is somewhat dependent on order / selector specificity but seems to work at least in my testing. I think the only possible alternative (that doesn't need a new crengine feature) is adding "smaller" variants for each footnote extension and the user having to make sure they match if they want consistent styling.

@moben
moben marked this pull request as ready for review April 17, 2025 00:10
@moben

moben commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

Marked as non-draft on the basis that I think koreader/crengine#618 is pretty much ready.

@moben

moben commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

@Commodore64user replying to you here instead of #13613 (comment) to keep the discussion more focused.

[...], although the extension stuff could go inside fix-up easily. Just add a separator and whack 'em at the bottom.

@poire-z and myself discussed that here. The reason I put them outside fix-ups is that fix-ups are all about how footnotes are styled, whereas the top level settings (and the new extension stuff) are about which lines are selected to be footnotes. And there might be more common cases like "until the next heading" that could go in the same menu (not sure which, would need more people to use it and report back).

I do find the names extend footnotes until next footnote and extend footnotes until next header or footnote a bit too overwhelming. I would suggest something more like extend footnote selection/content up to next footnote and extend footnote selection up to next header.

I tried that just now but I think it's too long. Everywhere I was able to test it's cut of and ellipsized.

@Commodore64user

Commodore64user commented Apr 17, 2025 •

Copy link
Copy Markdown
Member

Mmm… extend footnote selection up to next header has 37 chars, your extend footnotes until next header or footnote has 46. How can you fit 46 but not 37? extend footnote selection/content up to next footnote has 41 and that is yet, without removing one of the two words which are clearly a choice. Not sure what you are on about.

@moben

moben commented Apr 17, 2025

Copy link
Copy Markdown
Contributor Author

Well, my head didn't read those as a choice so it was a bit long. (and maybe I made a copy&paste mistake) 😅
Obviously fits with your wording and is a bit clearer, happy to switch to that.

Maybe the "until the next footnote" part should just be in the description, so it can be

  • extend footnote content
  • extend footnote content until next header

Every entry in this submenu would be until X or the next footnote anyway.

@Commodore64user

Copy link
Copy Markdown
Member

better to have the first as extend footnote content until next entry the two should be somewhat similar in char length ;)

Comment thread frontend/ui/data/css_tweaks.lua Outdated
Comment on lines +943 to +954
-cr-only-if: -fb2-document;
-cr-hint: footnote-inpage;
margin: 0 !important;
}
*, autoBoxing {
-cr-hint: late;
-cr-only-if: inpage-footnote;
font-size: 0.8rem !important;
}
*, autoBoxing {
-cr-hint: late;
-cr-only-if: extended-inpage-footnote;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't the first *, autoBoxing { content still be held in the *[role~="doc-rearnote"] {, to avoid a CSS check ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I think I was splitting it out because I was already thinking about #13613 and it needs to be separate there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduced this to one extra CSS check with koreader/crengine#620

Comment thread frontend/ui/data/css_tweaks.lua Outdated
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 is needed when books don't correctly mark all text that belongs to the footnote.]]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be / might be (because who are we to force inpage footnotes to the use ? :)) I think that's the tone we have in other tweak descriptions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread frontend/ui/data/css_tweaks.lua Outdated
{
title = _("In-page footnote extension"),
{
id = "following-footnote-inpage_all",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Dunno if _all is standardized elsewhere, but _any -or nothing- feels more accurate?)

@moben moben Apr 22, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to _any (and adjusted the id prefix to extend-footnote-inpage_following-inpage-footnote_ which I think fits with the existing naming scheme based on the -cr-hint / -cr-only-if that is applied or used).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels a bit long though :) (related to all the other ids).
extend-footnote-inpage_following-inpage-footnote_
May be just ("following inpage footnote" seems implied with "extend footnote inpage"):
extend-footnote-inpage_any
extend-footnote-inpage_until_next_heading
?
(Not enough energy to review the rest this evening.)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok, but still waiting for these to get shorter :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, had forgotten about this. They are shorter now 👍

Comment thread frontend/ui/data/css_tweaks.lua Outdated
Comment on lines +1071 to +1073
*, autoBoxing {
-cr-only-if: following-inpage-footnote -inpage-footnote;
-cr-hint: extend-footnote-inpage;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels that this, having a really low specificity, may not match those that get to be inpage-footnotes with *[type~="note"] or .footnote which has a higher specificity.
Is -cr-hint: late the solution ? Dunno how everything behave when multiple cr-hint late setting other hints... moreover when one would use -cr-only-if: extended-inpage-footnote...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's certainly more fragile, I'll do some testing with -cr-hint: late.

-cr-only-if: extended-inpage-footnote is essentially only needed to set the smaller font-size above for well behaved books where you don't need to force a single size via the -cr-only-if: inside-inpage-footnote hint.

We could also go back and make -cr-only-if: inpage-footnote also match extended footnotes. Less css but also less flexible. I at least found it useful in debugging to match the extended blocks specifically.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logically, -cr-only-if: inpage-footnote (named inpage-foonote, different from the hint name footnote-inpage) should match what has ended up being a footnote, not what had the hint.
So yes, I think it should also match extended footnotes.

Same for inside-inpage-footnote, which should match stuff inside an extended footnote block.

(I'm out for the day.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, changed it here and dropped the unneeded -cr-only-if: extended-inpage-footnote: koreader/crengine#620

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remembered why I didn't originally add late: I had problems with specificity like you hinted at.

I did what I think is the correct fix now by using -cr-hint: late to ensure it's applied after footnotes are marked as well as :where() and priority to ensure it's lower specificity than other late hints that style footnotes. (I only learned today that tweak order depends on the name of the tweak, so priority is actually necessary).

@poire-z

poire-z commented Apr 27, 2025

Copy link
Copy Markdown
Contributor

Will need a crengine into base bump, and a base into frontend bump.

Frenzie pushed a commit to koreader/koreader-base that referenced this pull request May 23, 2025
@poire-z

poire-z commented May 23, 2025

Copy link
Copy Markdown
Contributor

I think you need to bump base in this PR (if it should be merged before the other one).
Unless there's already another PR doing the bump (can't keep up :)).

@Commodore64user

Copy link
Copy Markdown
Member

image

@poire-z
poire-z merged commit 4116c6d into koreader:master May 25, 2025
@Frenzie Frenzie added this to the 2025.05 milestone May 25, 2025
0xstillb pushed a commit to 0xstillb/koreader-thai that referenced this pull request May 9, 2026
benoit-pierre pushed a commit to benoit-pierre/koreader that referenced this pull request Jul 25, 2026
benoit-pierre pushed a commit to benoit-pierre/koreader that referenced this pull request Jul 26, 2026
benoit-pierre pushed a commit to benoit-pierre/koreader that referenced this pull request Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants