-
DescriptionMy .qmd file contains chunks with multiple languages. Each chunk is successfully rendered (and exectued!). How can I have the language being used in each chunk automatically displayed, e.g. at the top corner? I know the An example from TileDB website (I believe to be built with Quarto, main repo here: ---
title: "Reproducible Quarto Document"
format:
html:
embed-resources: true
engine: knitr
---
Here is a `shell` chunk
```{bash}
echo "Hi there!"
```
Here is a `python` chunk
```{python}
print("Hello, world!")
```
And here is `R`!
```{R}
print(c("Bonjour!"))
``` |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
You can make a Lua filter to set filename. |
Beta Was this translation helpful? Give feedback.
-
TileDB book does not seem to have any Lua filters set up, and it also does not seem to rely on |
Beta Was this translation helpful? Give feedback.
-
Here is a simple Lua filter to add filename using the code cell language. function CodeBlock(code)
local lang = code.attr.classes[1]
if lang == "cell-code" then
_, _, matchedLang = string.find(code.text, "^`+%{%{([^%}]*)%}%}")
lang = matchedLang or lang
elseif lang ~= nil and lang:find('{{', 1, true) == 1 then
_, _, matchedLang = string.find(lang, "{{+(.-)}}+")
if matchedLang then
lang = matchedLang
end
end
return quarto.DecoratedCodeBlock({
filename = lang,
code_block = code:clone()
})
end |
Beta Was this translation helpful? Give feedback.
Here is a simple Lua filter to add filename using the code cell language.