-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Redundant removal of attributes on HTML headers #865
Comments
Thanks for the analysis! There is indeed redundancy. For bookdown, we have to keep a07ae07, so the only option is to get rid of |
?
This isn't an option? |
I don't know how to do this...
|
Overall, I think we should make JS script in rmarkdown more conditional than they are. So that a user can decide to opt-out a feature brought by a JS script if desired. Doing so in rmarkdown would allow to opt-out in bookdown. Otherwise, maybe we should start setting a knitr option in each package format so that rmarkdown can sometimes adapt its behavior depending on which the format is ? Like we do for bookdown label but more generic, something like knitr:::opts_knit$set(bookdown = TRUE) This would be set in a bookdown format, so that it can be used by other packages that needs to modify their behavior. @yihui what do you think ? |
Perhaps adding so that we can set this option to |
Yes I think that would be the better. This would be a way also to opt-out of this if desired. I think this is good practice if we can offer an opt-out flag when we add things like CSS or JS. Regarding this |
Another thing I've noticed: The header attribute removal executed by Since Why do header attributes need to be removed in the first place again? |
This is a long old story due to a Pandoc change but it started here: rstudio/rmarkdown#1723 As commented in the file (https://github.com/rstudio/rmarkdown/blob/e44a23f3e508534966717e9c9dce07afd2e37002/R/html_dependencies.R#L440)
At first it was a quick fix for tabsets in rmarkdown following a change in Pandoc 2.8, and then became more generic for other format (like flexdashboard (rstudio/rmarkdown#1732) . At last, it was changed to the current code applied only for Pandoc 2.9 and later (rstudio/rmarkdown@7f51e23) so that it works the same for different pandoc version (except 2.8 which will be buggy anyway). We still need to provide an opt out way as discussed in #865 (comment) This will be done for next version of rmarkdown |
… formats in order to deactivate double handling of header attributes Closes #865. Requires rmarkdown 2.12
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. |
I just noticed that when using Bookdown/Blogdown in combination with Pandoc 2.9+, the following JavaScript dependency gets inserted in the rendered HTML:
The content of
header-attrs.js
is found here and was added with rstudio/rmarkdown@7f51e23.At the same time, the R function
bookdown:::clean_header_tags()
removes those attributes during rendering (added with a07ae07).So – if I didn't miss anything – this header attribute removal is done twice: At first during rendering the R Markdown to HTML using R code (fine) and a second time during rendering the HTML by the browser using JS code (redundant and thus obsolete in the case of Bookdown/Blogdown).
Therefore I think it would make sense to avoid adding this JS dependency when bookdown/blogdown renders a file. Or maybe, the R-based header attribute removal could be performed directly by
rmarkdown::render()
(instead of adding the JS).(IMHO: The less JS, the better 😬)
By filing an issue to this repo, I promise that
xfun::session_info('bookdown')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/bookdown')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: