Skip to content

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented May 2, 2022

it should not be pass through so that it does not end up into the div when pass as a knitr option.

This option is new from knitr 1.38 (https://github.com/yihui/knitr/blob/master/NEWS.md#changes-in-knitr-version-138)

I don't think this option lang has any effect in Quarto yet. So we have a difference in behavior between knitr in R Markdown and in Quarto.

With knitr, lang is used in various place to change the language that will be applied as class to the code chunk in Markdown. Default is the engine. Sometimes it needs to be tweaked.

Example:

```{verbatim, lang = "js"}
console.log('test')
```

This is used in knitr to output a code chunk of class js

```{bash, lang = "default"}
pwd
```

This is used to execute a chunk as bash but highlight as a default block.

So this PR only makes sure that the option is correctly identified a knitr option. I'll make another one (or just continue in this one if you prefer) to make the recent engine (verbatim, embed, comment, ...) works correctly. They are not really working as expected I believe (mainly because we overwrite the source hook I think).

@cderv
Copy link
Collaborator Author

cderv commented May 2, 2022

I added support for

```{embed, file = "special-highlight.lua"}
```

in addition of the verbatim engine.

There is still the cat engine that has a specific behavior depending on the source hook (that quarto replace). I am still onto this.

And this probably need to tests.

@yihui maybe we need to reorganize and refactor in knitr so that we could maybe not rewrite things too much and so that Quarto can directly use some knitr function.

@cderv cderv changed the title lang is a valid knitr option Improve support of specific knitr engines for source output May 2, 2022
Copy link
Contributor

@yihui yihui left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yihui maybe we need to reorganize and refactor in knitr so that we could maybe not rewrite things too much and so that Quarto can directly use some knitr function.

Sure! We should definitely do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants