yihui / knitr

A general-purpose tool for dynamic report generation in R
https://yihui.org/knitr/
2.39k stars 878 forks source link

Different html rendering when output is set to epub2 #2145

Closed flipacholas closed 2 years ago

flipacholas commented 2 years ago

By filing an issue to this repo, I promise that

I understand that my issue may be closed if I don't fulfill my promises.


My session:

R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur ... 10.16

Locale: en_GB.UTF-8 / en_GB.UTF-8 / en_GB.UTF-8 / C / en_GB.UTF-8 / en_GB.UTF-8

Package version:
  base64enc_0.1.3 bslib_0.3.1     digest_0.6.29   evaluate_0.15  
  fastmap_1.1.0   fs_1.5.2        glue_1.6.2      graphics_4.2.1 
  grDevices_4.2.1 highr_0.9       htmltools_0.5.2 jquerylib_0.1.4
  jsonlite_1.8.0  knitr_1.39      magrittr_2.0.3  methods_4.2.1  
  R6_2.5.1        rappdirs_0.3.3  rlang_1.0.3     rmarkdown_2.14 
  sass_0.4.1      stats_4.2.1     stringi_1.7.6   stringr_1.4.0  
  tinytex_0.40    tools_4.2.1     utils_4.2.1     xfun_0.31      
  yaml_2.3.5     

Pandoc version: 2.18

I think there is (undesirable?) behaviour present when rendering epubs using the epub_version attribute set to epub2. Basically, after embedding images on a document with caption (using fig.caption), if the document is rendered using bookdown and epub_version is set to epub3 or epub, knitr will render <p class="caption"> block with the caption (as expected). On the other hand, if it's set to epub2, the caption block is not rendered.

At first, I thought this was an issue of bookdown, but I found this line that may be the culprit:

https://github.com/yihui/knitr/blob/17ef462e3b5e8fa344556e05c9a9833225ccca4c/R/utils.R#L382

(probably should include "epub2" as well?)

yihui commented 2 years ago

Yes, it should include epub2. Would you like to send a pull request? Thanks!

flipacholas commented 2 years ago

Done!

github-actions[bot] commented 1 year ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.