Disable running C programs with R #7770
-
DescriptionI wrote a Lua filter to run programs in C and preview both compile errors and program output. It runs the GCC with My intent is to allow programs with errors to be compiled and shows the compiler errors and warnings. It was working fine until I added an R code in a chapter in my book project. Somehow now R (I think) gains control of Since some programs in C do have errors, the Quarto rendering stops due such errors. Question: Is there a way to tell Quarto to ignore running C programs by its own when R code is present? I hope my description is clear enough. All my tests where done on a Linux machine (Debian) and standard gcc compiler. This zip file has the code: code.zip. The |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
That's the engine binding. To disable computation of a code cell use Note that sharing zip archive instead of plain text or repository make it very difficult for people with disabilities to access your content. (It is also more effort to everyone to use it). You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four ````qmd
---
title: "Reproducible Quarto Document"
format: html
---
This is a reproducible Quarto document using `format: html`.
It is written in Markdown and contains embedded R code.
When you run the code, it will produce a plot.
```{r}
plot(cars)
```

The end.
```` |
Beta Was this translation helpful? Give feedback.
-
You are doing advanced usage by trying to use a Lua filter to add support for a computation language, and Quarto does not have yet a good mechanism for this. So as your filter applies after the computation stage, you need to take into account what Quarto computation means regarding to syntax and Engine binding. Let me explain.
Your Lua filter is targeting CodeBlock with I do believe this mean you don't expect Quarto to do anything with the C codeblock and just pass it over for Lua to run according to your filter.
Considering this feedback, and your filter, I see you are using the specific Quarto syntax for computational Code block (https://quarto.org/docs/computations/r.html#code-blocks) and not just source code block (https://quarto.org/docs/authoring/markdown-basics.html#source-code). The syntax differs in the way you set the language ```{c} versus ```c The latter is a regular code block for Quarto, which means no computation Engine Binding is applied. The source code block is like a usual Pandoc's Markdown code block. However, when you use the former, it will be seen as a computation chunk. So the Engine Binding will apply.
So here I believe there is either a different usage to make or adapt to the context Either don't use Quarto computation syntax for code block. Meaning you should use ```c instead of ```{c} This means your lua filter should be adapted to if block.attr.classes:includes("c") instead of if block.attr.classes:includes("{c}") Or you need to be sure knitr engine won't process your C block by unsetting the C engine in your R configuration so that when R is used, the C blocks are handled by your Lua filter knitr::knit_engines$delete('c') It could also be modified with There could be a warning, but this is because then using Anyhow, I hope this clarifies the situation. |
Beta Was this translation helpful? Give feedback.
That's the engine binding.
It's either knitr or Jupyter.
If you don't set it Quarto will automatically detect which engine to use. Python code cell implies Jupyter, R code cell implies knitr.
Use
engine: XXX
to make it explicit.To disable computation of a code cell use
eval: false
.Note that sharing zip archive instead of plain text or repository make it very difficult for people with disabilities to access your content. (It is also more effort to everyone to use it).
You can share a Quarto document using the following syntax, i.e., using more backticks than you have in your document (usually four
````
).