-
-
Notifications
You must be signed in to change notification settings - Fork 978
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
Allow to load external highlighting theme for Pandoc HTML and PDF #2035
Comments
I'd suggest something like this so that users can easily specify custom definition like highlight <- tryCatch(
match.arg(highlight, html_highlighters()),
error = function(e) {
if (file.exists(highlight)) return(highlight)
stop(e$message, ", or a custom definition file.")
}
) |
Thank you for this suggestion ! This is currently a limitation that should be overcome in this (rather large) PR. It is not specific to this issue, but it refactor the whole highlighting logic and thus a There is currently not an easy work around due to the order of flags passed to Pandoc. Instead of hacking with html_doc <- function() {
base_format <- rmarkdown::html_document(highlight = NULL)
pandoc_args <- base_format$pandoc$args
pandoc_args[pandoc_args == "--no-highlight"] <- "--highlight-style=my.theme"
base_format$pandoc$args <- pandoc_args
base_format
}
rmarkdown::render("test.Rmd", html_doc()) |
* Allow to pass a custom .theme file in highlight argument (close #2035) * Add two custom themes: arrow.theme and rstudio.theme, the former optimized for accessibility * Add optional support for downlit as a syntax highlighter, using Pandoc's theme for styling (close #1881) Co-authored-by: Hadley Wickham <[email protected]>
@royfrancis for HTML you can now use the I'll reopen this one and edit title as I have done 50% of the work. I'll do PDF support soon |
And support has now been adding
|
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 have a customized
pandoc
syntax highlighting theme that I would like to use for myRmd
file:my.theme
. For PDF output this can be achieved easily by using the following YAML header:Unfortunately the same wouldn't work for
html_document
. While the console output shows--highlight-style=my.theme
was successfully passed topandoc
, thepandoc_html_highlight_args()
utility attached an argument--no-highlight
to the end which then overtakes the previous argument. Statinghighlight: my.theme
is not an option either sincepandoc_html_highlight_args()
will do amatch.arg
check. The only work around I can think of is to usetrace()
to intercept thepandoc_args
insiderender()
before it was passed topandoc_convert()
, and this is obviously a terrible idea.A fix shouldn't be too complicated though. Maybe an option
customized
can be added to the output ofhtml_highlighters()
? In which casepandoc_html_highlight_args()
will stop attaching further arguments so that--highlight-style
can be processed correctly.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: