-
-
Notifications
You must be signed in to change notification settings - Fork 981
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
offer a HTML5 compatible format as html_document()
is HTML4 only
#1776
Comments
I think that indeed the support for HTML5 can be improve here. Just to complete, I don't know how yet the I think without a big impact we could either insure that if a Let's not that you could also create your own Here is an example where you can see that html5_document <- rmarkdown::output_format(
# this is required but will be override by the base_format
knitr = NULL,
# this will be merge with the base_format, modifying the default html -> html4
pandoc = list(to = "html5"),
# use your html_document with correct option as a base format to modify
base_format = rmarkdown::html_document(
fig_width = 8,
fig_height = 6,
toc = TRUE,
theme = NULL,
highlight = "pygments",
md_extensions = "-autolink_bare_uris",
self_contained = FALSE,
# I don't have this template file
# template = "journal.html5"
)
)
# working in a temp folder for the example
dir.create(tmp_dir <- tempfile())
old <- setwd(tmp_dir)
xfun::write_utf8(c(
"---",
"title: test",
"---",
"",
"# title test"
), "test.Rmd")
# enforcing the custom output_format
rmarkdown::render("test.Rmd", output_format = html5_document)
#> processing file: test.Rmd
#> output file: test.knit.md
#> "C:/PROGRA~3/CHOCOL~1/bin/pandoc" +RTS -K512m -RTS test.utf8.md --to html5 --from markdown+tex_math_single_backslash-autolink_bare_uris+smart --output test.html --email-obfuscation none --standalone --section-divs --table-of-contents --toc-depth 3 --template "C:\Users\chris\Documents\R\win-library\3.6\rmarkdown\rmd\h\default.html" --highlight-style pygments --include-in-header "C:\Users\chris\AppData\Local\Temp\RtmpGyb1a2\rmarkdown-str5bcc7ee71a7c.html" --mathjax --variable "mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua" --lua-filter "C:/Users/chris/Documents/R/win-library/3.6/rmarkdown/rmd/lua/latex-div.lua"
#>
#> Output created: test.html
setwd(old) Created on 2020-02-23 by the reprex package (v0.3.0.9001) I think this is currently the way to go to customize an output format and change some default behavior. This Hope it helps. |
Merci bien, cderv! |
html_document()
is HTML4 only
This just became very relevant for me. It turns out, pandoc started to escape This specifically broke all toc entries in my document that do not consisted solely of ascii characters:
A way to tell pandoc to use |
Thanks for the feedback. This is not a trivial addition to R Markdown, and nowadays effort for new feature as focus on Quarto. If you don't know quarto, this is really similar to R Markdown approach, and it is based on years for experience. See https://quarto.org and https://quarto.org/docs/faq/rmarkdown.html The HTML format offered by Quarto is using html5: https://quarto.org/docs/output-formats/html-basics.html So if you are working on new project, this is a good tool to start with for those project. You would get HTML5 right away, with a bunch of new features, while having all the benefits of R Markdown and knitr that you already leverage.
HTML5 or HTML4 aside, this looks like an issue with newer pandoc that I need to look at 🤔 |
If you want to use R Markdown (not Quarto), then my minidown package would help you. |
Thanks @atusy I did not realize it was using HTML5 ! Really cool ! Thank you ! |
There is a quite old commit forcing rmarkdown --> pandoc to render all html documents as html4. Mostly I use my own html5 templates but even putting in YAML something like:
there is
--to html4
in output meaning that pandoc uses it. The only working solution is manually "revert" those strings in rmarkdown sources locally and rebuild it at every update. And when I need to use e.g. bookdown, which relies on (deprecated?) html4, I install CRAN version again. A bit uncomfortable.Maybe let it to user to specify the version of html? For convenience, let default variant be "html4" but user should can to simply put "html5" somewhere in YAML-block to have html5 file in output.
By filing an issue to this repo, I promise that
xfun::session_info('rmarkdown')
. 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/rmarkdown')
.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: