rstudio / bookdown

Authoring Books and Technical Documents with R Markdown
https://pkgs.rstudio.com/bookdown/
GNU General Public License v3.0
3.71k stars 1.27k forks source link

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

Closed cderv closed 1 year ago

cderv commented 1 year ago

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)

cderv commented 1 year ago

Also closes https://github.com/rstudio/bookdown-demo/issues/42

cderv commented 1 year ago

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