Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Footnote pop-up and backreference links #123

Merged
merged 16 commits into from
Jan 6, 2025

Conversation

gambhiro
Copy link
Contributor

@gambhiro gambhiro commented Nov 7, 2024

This adds an option to add backreference links at the end of footnote definitions, so that the user can return and continue reading the main body of the text.

The code is based on the footnote-rewrite.rs example.

The pop-up footnote behaviour requires the use of <aside> tag and so EPUB 3 is required.

[output.epub]
epub-version = 3

I think most users would expect this behaviour and so I set the footnote-backrefs option to true by default, but it is only used when epub-version = 3 is already selected.

On a Kindle Paperwhite, the footnote definition appears in a pop-up bottom window when the footnote reference number is tapped.

In KOReader on Remarkable 2 the footnote definition appears at the bottom of the screen.

The footnote definitions include a backreference link to jump back to the main body of the text.

This feature was also discussed at #65

@blandger
Copy link
Collaborator

blandger commented Jan 3, 2025

Seems like there is new compiler version issue.

@gambhiro
Copy link
Contributor Author

gambhiro commented Jan 4, 2025

@blandger It passes the checks now 👍

@dieterplex
Copy link
Contributor

This PR deserves to have footnotes in markdown page of integration tests for users to know how to use. Maybe we can add another dummy to build ePub3 book and to verify it?

self.hbs.render("index", &ctx)
}

fn render_with_footnote_backrefs(&self, chapter_dir: &Path, ch: &Chapter) -> String {
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe extracting closures at L304 & L385 to functions would improve readability. And extracting link filter logic to a function may reduce repetition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I managed to extract the one that was at L304 with the compiler messages helping me through it, but the other one gave me errors that I don't know how to deal with.

@gambhiro
Copy link
Contributor Author

gambhiro commented Jan 4, 2025

another dummy to build ePub3 book

I added a dummy with epub-version = 3 option and some tests to check that footnote backreference links are generated.

src/config.rs Outdated Show resolved Hide resolved
@blandger
Copy link
Collaborator

blandger commented Jan 5, 2025

This PR deserves to have footnotes in markdown page of integration tests...

Agree.

I even think about several 'dummy book' examples/instances with different checking aspects. Like one book is for checking links between pages, another for local images check, third is for remote images check.

@blandger
Copy link
Collaborator

blandger commented Jan 5, 2025

Fixes were merged. Several libs are updated. Pls upgrade your branch by master.

@gambhiro
Copy link
Contributor Author

gambhiro commented Jan 5, 2025

Pls upgrade your branch by master

Seems ok now 👍

src/generator.rs Show resolved Hide resolved
tests/dummy_epub3/book.toml Outdated Show resolved Hide resolved
@blandger
Copy link
Collaborator

blandger commented Jan 5, 2025

Overall I like that feature in the epub book, it looks very convenient and works fine (on my onyx ebook). Popup footnotes is what I really miss inside PDF books.

@blandger blandger merged commit 1739330 into Michael-F-Bryan:master Jan 6, 2025
2 checks passed
@gambhiro gambhiro deleted the footnote-popup-backref branch January 6, 2025 14:12
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.

3 participants