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

Fix issue with cross referencing figures and tables in epub #1426

Merged
merged 3 commits into from
May 4, 2023

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented May 4, 2023

It seems we were correctly resolving the references, and adding a link to it, but no anchor id anywhere as we do for HTML

This changes insert an anchor id inside an empty span in the caption part. This is a quick solution as the id should be probably added to the figure or table itself.

this fixes #766

Chnages has been tested with bookdown-demo and epubcheck

Initially we had

Validating using EPUB version 3.3 rules.
ERROR(RSC-005): bookdown-demo.epub/EPUB/text/ch002.xhtml(84,74): Error while parsing file: value of attribute "width" is invalid; must be an integer
ERROR(RSC-012): bookdown-demo.epub/EPUB/text/ch002.xhtml(79,247): Fragment identifier is not defined.
ERROR(RSC-012): bookdown-demo.epub/EPUB/text/ch002.xhtml(89,123): Fragment identifier is not defined.
ERROR(RSC-012): bookdown-demo.epub/EPUB/text/ch002.xhtml(89,252): Fragment identifier is not defined.

Check finished with errors
Messages: 0 fatals / 4 errors / 0 warnings / 0 infos

with this PR we have

Validating using EPUB version 3.3 rules.
ERROR(RSC-005): bookdown-demo.epub/EPUB/text/ch002.xhtml(84,94): Error while parsing file: value of attribute "width" is invalid; must be an integer
ERROR(RSC-012): bookdown-demo.epub/EPUB/text/ch002.xhtml(79,247): Fragment identifier is not defined.

Check finished with errors
Messages: 0 fatals / 2 errors / 0 warnings / 0 infos

The last one is related to section reference I think (see #890)

It seems we were correctly resolving the references, and adding a link to it, but no anchor id anywhere as we do for HTML

This changes insert an anchor id inside an empty span in the caption part. This is a quick solution as the id should be probably added to the figure or table itself.
@cderv cderv requested a review from yihui May 4, 2023 11:38
@cderv cderv mentioned this pull request May 4, 2023
3 tasks
@cderv
Copy link
Collaborator Author

cderv commented May 4, 2023

Also closes rstudio/bookdown-demo#42

Copy link
Member

@yihui yihui left a comment

Choose a reason for hiding this comment

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

Sounds good. I'd prefer this simple fix, too. Thanks!

R/ebook.R Outdated Show resolved Hide resolved
@yihui yihui merged commit 8442b5a into main May 4, 2023
13 checks passed
@yihui yihui deleted the fix/epub3/links branch May 4, 2023 13:57
@cderv
Copy link
Collaborator Author

cderv commented May 4, 2023

Great ! We need to figure out #890 now... Not sure what is wrong yet...

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants