Skip to content
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

Provide a syntax definition file with updated support for R new syntax #2196

Open
cderv opened this issue Jul 28, 2021 · 10 comments · May be fixed by #2290
Open

Provide a syntax definition file with updated support for R new syntax #2196

cderv opened this issue Jul 28, 2021 · 10 comments · May be fixed by #2290
Assignees
Labels
feature a feature request or enhancement next to consider for next release theme: highlight theme: pandoc concerns upstream pandoc

Comments

@cderv
Copy link
Collaborator

cderv commented Jul 28, 2021

First issue has been reported in rstudio/bookdown#1157. See discussion there for details. In a nutshell:

  • Pandoc's highlighting uses KDE XML syntax file
  • the KDE XML syntax file for R language does not correctly handles the new R syntax.

Current fix in rmarkdown is for html_document_base() only as a post processing - see 99df4e7 . This fixes the issue rstudio/bookdown#1157

Proper fix should be:

  • Push upstream correct support for Pandoc for later Pandoc's version.
  • Use the XML definition file directly in rmarkdown for previous pandoc version that won't have the updated support, using --syntax-definition flag.
@cderv cderv added feature a feature request or enhancement theme: pandoc concerns upstream pandoc labels Jul 28, 2021
@cderv cderv self-assigned this Jul 28, 2021
@cderv
Copy link
Collaborator Author

cderv commented Aug 16, 2021

From a report in tidyverse/reprex#389, let's acknowledge that the current fix is not working for github_document() HTML preview

---
title: "Minimal Example"
output: 
  github_document: default
  html_document:
    highlight: pygments
---

```{r}
library(magrittr)
1.23 %>% round()
1.23 |> round()
```

@cderv
Copy link
Collaborator Author

cderv commented Oct 4, 2021

Waiting for this to be completely fixed, I published a gist with a patched xml file one could use: https://gist.github.com/cderv/079b78caefbe45da6d1c03d737970b55

It can be downloaded then used by adding pandoc_args in YAML header. e.g with pdf_document()

output: 
  pdf_document:
    pandoc_args: "--syntax-definition=r.xml"

See comment here for more detail and example on how to set a font for having the ligature in PDF

rstudio/bookdown#1157 (comment)

@yihui
Copy link
Member

yihui commented Oct 4, 2021

Could you submit a PR to KDE? I guess this is the file to edit: https://invent.kde.org/frameworks/syntax-highlighting/-/blob/master/data/syntax/r.xml The earlier we submit a PR, the better, since it will take time for the upstream change (if merged) to propagate to Pandoc.

@cderv
Copy link
Collaborator Author

cderv commented Oct 4, 2021

I wanted to try add support for new syntax to define function too

(\(x) x + 1)(2)
#> [1] 3

But I still haven't done the KDE file update for this.

You're right I should do it wit the current addition.

@cderv
Copy link
Collaborator Author

cderv commented Jan 24, 2022

PR opened in KDE repo: https://invent.kde.org/frameworks/syntax-highlighting/-/merge_requests/295

@cderv
Copy link
Collaborator Author

cderv commented Jan 25, 2022

PR has been merged - they dealt with the KDE specific compilation. This means that next Pandoc version should have the new file included as they pull from the KDE repo in https://github.com/jgm/skylighting to be included in Pandoc.

@cderv cderv moved this from Todo to In Progress in R Markdown Team Projects Jan 25, 2022
@cderv cderv moved this from In Progress to Todo in R Markdown Team Projects Mar 1, 2022
@yihui
Copy link
Member

yihui commented Mar 10, 2022

It seems skylighting has picked up the changes: jgm/skylighting@8bb0095#diff-250158d7bb3fc1cdf086670cbd7ea7fe8ccb68f6004b3739b36960d574372e35

I guess we should also submit a PR to KDE with 5514393, right?

@cderv
Copy link
Collaborator Author

cderv commented Mar 10, 2022

Yes it has picked up the change and also Pandoc (jgm/pandoc@2a70d9c) but not yet in a release. Next one should have it.

I have still a PR in skylighting for markdown.xml from Quarto but not sure it will be merged.

PR for KDE with last change is ready but not yet online. I have prepare that yesterday with the changes in the PR.

@cderv cderv moved this from Todo to Backlog in R Markdown Team Projects Apr 8, 2022
@yihui
Copy link
Member

yihui commented Sep 15, 2023

Yes it has picked up the change and also Pandoc (jgm/pandoc@2a70d9c) but not yet in a release. Next one should have it.

It seems to be shipped in Pandoc 2.18. The RStudio IDE uses Pandoc 3.x now, so perhaps we can drop r.xml in the #2290? (which means we just don't support syntax highlighting the pipe operators for Pandoc < 2.18 users)

@cderv
Copy link
Collaborator Author

cderv commented Sep 19, 2023

Yes it seems ok to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement next to consider for next release theme: highlight theme: pandoc concerns upstream pandoc
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

2 participants