-
Notifications
You must be signed in to change notification settings - Fork 331
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Inline literal r code within formatted fenced code #11810
Comments
This isn't really a bug in quarto. The Removing the fenced code block means that Quarto's automatic engine detection doesn't kick in, and so you get the "markdown" engine which doesn't do anything. @cderv might know how to get knitr to ignore some code cells. |
I believe you need to use To note, this is definitely not a bug, that's a long time
|
This being said, since Quarto harmonised the inline syntax with brackets: Note that Pandoc syntax for this is https://pandoc.org/MANUAL.html#highlighting
|
This is indeed the official syntax for highlighting inline code in typst. It will produce this raw code #raw(lang:"r", "1 + 1") This could also be used directly
This
The problem here is indeed because This would like this ---
title: example1
format: typst
keep-typ: true
keep-md: true
---
```{r}
#| echo: false
raw_inline <- function(x, lang, format) {
sprintf("```` ```%s %s ``` ````{=%s}", lang, x, format)
}
```
inline code: `r raw_inline("1 + 1", "r", "typst")`
```{r}
1 + 1
```
So in conclusion, this is unfortunate conflict between knitr syntax and Typst syntax, and how knitr works to parse document. So there are workaround fortunately
One big change we could try do in the future, it introduce an option in knitr to allow quarto to completely deactivate original knitr inline syntax to only support the Quarto inline syntax
It is an evolution to make in knitr and Quarto if we want to go this road. Hope this clarify the problem here. |
Thank you all for the quick replies! I love the explanations! I truly wanted to have some inline syntax highlighting for my presentation, and I ended up doing something of the following to cut down on having overly verbose markdown syntax ```{=typst}
#set raw(lang: "r")
``` And then I wrote a quarto filter to inject I will go ahead and close the issue, thanks again! |
I’m converting to discussions for better discovery in the future. Could you share your filter for others? |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Bug description
I am unsure how deep this bug goes, but this was discovered trying to use literal typst formatting for R code. The reason being that attempting to syntax highlight with typst they expect the following
```r 1 + 1```
, thus the.qmd
format would look something like```` ```r 1 + 1``` ````{=typst}
However, there is a very odd bug when trying to place fenced computed code within a literal formatted code while another fenced r block exists in the file. This seems to be an issue specifically with r computed code, as this issue does not arise with python (even when using knitr engine).
Steps to reproduce
Which will yield a
.typ
file such as:However omitting the fenced R block (specifically the
```{r} ... ```
pattern):will yield the expected
.typ
file output:inline code: ```r 1 + 1```
Expected behavior
example1 should yield a
.typ
file with:Actual behavior
See above
Your environment
Quarto check output
The text was updated successfully, but these errors were encountered: