-
-
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
Make it easy to use downlit from html_document() #1881
Comments
Why not in bookdown too? 🙂 |
@maelle If supported in rmarkdown output format, it should be supported in bookdown too. ( |
Currently implemented in the development version of distill: https://github.com/rstudio/distill/blob/master/NEWS.md#distill-v09-development |
I started to look into this to get a sense of how it works and what we could do. We could offer a Re. how : There is I tend to find the use of the Have I missed something ? Should we adjust those two functions to be more the same ? or should I go the distill way and build with knitr to apply downlit transformation ? |
You can supply the |
I need to understand better where to when to apply downlit processing to be sure we keep other Pandoc highlighting.
I'll keep testing. As rmarkdown format are for more general use than specific one like |
It sounds tough to take care of Pandoc AST... |
Or to prevent Pandoc from highlighting R code blocks, rename R to notAnActualProgrammingLanguage. 🙊 Then downlit could highlight them. |
IMO there is not really an easy way to support markdown output. Syntax highlighting with HTML in markdown output would depend on the HTML renderer when previewed. It works for I believe we should just support HTML document for now. That is what the PR is doing. |
Agreed; adding downlit to |
TIL: Pandoc highlighter does not understand correctly the R native pipe. This leads to not so nice highlighting in ---
title: test
output:
html_document:
highlight: pygments
---
```{r}
f <- function(x) { x + 1 }
2 |> f()
```
```{r}
(\(x) x + 1)(2)
``` I believe this would require to teach Pandoc syntax highlighter and / or theme. Using downlit helps with this, and would be working with any Pandoc version. Example from PR #1941 ---
title: test
output:
html_document:
highlight_downlit: TRUE
highlight: pygments
---
```{r}
f <- function(x) { x + 1 }
2 |> f()
```
```{r}
(\(x) x + 1)(2)
``` Noting this here to not forget I looked into this. |
* 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]>
It should now be possible to use downlit syntax highlighting and auto linking in It won't work yet for some of the derived format like blogdown when Pandoc is not used, or bookdown because currently downlit messes up the HTML file with xml2 which breaks the weak post processing in bookdown I'll open a new issue to track downlit auto-linking support for |
@cderv we should also figure what needs patching to support the native pipe in pandoc's highlighter. |
Yes this is tracked in #2196 to provide a specific syntax file to Pandoc for this. Also a patch to send upstream. I'll also check what downlit it doing. Not sure it does highlight specifically the operator downlit::highlight("1:3 |> mean()", downlit::classes_pandoc())
#> [1] "<span class='fl'>1</span><span class='op'>:</span><span class='fl'>3</span> |> <span class='fu'><a href='https://rdrr.io/r/base/mean.html'>mean</a></span><span class='op'>(</span><span class='op'>)</span>" I think it should be like library(magrittr)
downlit::highlight("1:3 %>% mean()", downlit::classes_pandoc())
#> [1] "<span class='fl'>1</span><span class='op'>:</span><span class='fl'>3</span> <span class='op'>%>%</span> <span class='fu'><a href='https://rdrr.io/r/base/mean.html'>mean</a></span><span class='op'>(</span><span class='op'>)</span>" |
Can you please file an issue in downlit so I don't forget about it? |
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. |
So you can easily get R powered syntax highlighting and autolinking.
(And probably also worth supporting in
github_document()
andhtml_document()
)The text was updated successfully, but these errors were encountered: