Replies: 7 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. |
Beta Was this translation helpful? Give feedback.
-
I believe you need to use To note, this is definitely not a bug, that's a long time
|
Beta Was this translation helpful? Give feedback.
-
This being said, since Quarto harmonised the inline syntax with brackets: Note that Pandoc syntax for this is https://pandoc.org/MANUAL.html#highlighting
|
Beta Was this translation helpful? Give feedback.
-
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. |
Beta Was this translation helpful? Give feedback.
-
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! |
Beta Was this translation helpful? Give feedback.
-
I’m converting to discussions for better discovery in the future. Could you share your filter for others? |
Beta Was this translation helpful? Give feedback.
-
Sure, I spent some time to make this filter a bit more generalized than to use only with typst: https://github.com/jtlandis/default-lang The above will be more of a direct approach of adding a language to each unclassed inline code or code block (as specified by yaml header). Cheers! |
Beta Was this translation helpful? Give feedback.
-
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
Beta Was this translation helpful? Give feedback.
All reactions