-
I'm trying to create a new code chunk engine, e.g.: ```{webr}
1 + 1
``` I mirrored how the https://github.com/quarto-ext/shinylive/tree/main However, this works well when the ---
title: "Testing"
format: html
engine: knitr
filters:
- webr
---
```{webr}
1 + 1
``` Warning message:
In get_engine(options$engine) :
Unknown language engine 'webr' (must be registered via knit_engines$set()). Outside of creating a warning, this also causes the pandoc filter to receive a jupyter
knitr
This requires the filter checking inclusion on: el.attr.classes:includes("{webr}") # Jupyter
el.attr.classes:includes("webr") # knitr Is there a way to register engine requirements or options in a quarto extension, e.g. The extension code can be found at: https://github.com/coatless/quarto-webr |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
For Also @coatless you might want to make a PR to register comment character for chunk option as discussed for |
Beta Was this translation helpful? Give feedback.
-
Hi @coatless, Glad to see you jump into making this extension ! We were planning on doing it like shinylive as we thought that there would be some adjustment in quarto to make and this is effectively the case. You found some limitation that we need to think through.
So to this question: Not yet - no there is not, and maybe there should be indeed. I remember there was once already the question about Quarto extension for custom cell handlers, but this was not yet something we could offer easily, as best integration would be internal to Typescript code base, like we did for Below more more context on what you are encountering (sorry for the long answer, I wanted to give as much details as needed, also for later reference to this question) The warning you see is thrown by knitr because it sees the code chunk with engine as it is using the same syntax as using code cells, and then apply logic as any other engine. But for this one, there is no specific R engine as the code cell should be handled directly by your extension. Note one trick : Using However, this works with ---
title: "Testing"
format: html
engine: knitr
filters:
- webr
---
```{.webr}
1 + 1
``` knitr will ignore those for sure because this is the usual Pandoc Markdown syntax for Codeblock with attributes, and your filter correctly handle the That would be the right way to go with Pandoc only to define such CodeBlock handler in Lua filter. And this goes with the idea of cells engine to knitr or jupyter for now, except internal I understand though that user experience and other cell handler like About the context of current situation our internal cell handler. When defining a cell language handler that is not supposed to be handled by knitr (like mermaid or dot internal to Quarto), knitr should be aware of those and effectively just pass through the content with attributes. This is what is done with those two internal Having the extension registering this information to be pass through to knitr seems a good idea. But maybe we need some adjustment to knitr itself to ignore some code cells.
Regarding this, it is not as simple. I don't know if we want to "register" every custom engine this way. I'll open an issue to track and discuss further the general case. (#4839) Hope it helps. |
Beta Was this translation helpful? Give feedback.
-
We've now got the dash based variations (e.g. For now on options I think the best way is to parse them within your extension (we will hopefully in v1.4 do this for you automagically but that's not 100% guaranteed so it might be better just to get it working in the meantime) |
Beta Was this translation helpful? Give feedback.
Hi @coatless,
Glad to see you jump into making this extension ! We were planning on doing it like shinylive as we thought that there would be some adjustment in quarto to make and this is effectively the case. You found some limitation that we need to think through.
So to this question: Not yet - no there is not, and maybe there should be indeed. I remember there was once already the question about Quarto extension for custom cell handlers, but this was not yet something we could offer easily, as best integration would be internal to Typescript code base, like we did for
ojs
,mermaid
and