Skip to content

Instantly share code, notes, and snippets.

@cderv
Last active May 30, 2023 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cderv/9b7049780f75fb2c0e370a6aaa1feef3 to your computer and use it in GitHub Desktop.
Save cderv/9b7049780f75fb2c0e370a6aaa1feef3 to your computer and use it in GitHub Desktop.
Get some component out of a Qmd document
* Set `lang-out` to the language to ignore
* Use the LUA filter to remove the element mark with the language
```
quarto pandoc --to markdown -L lang-out.lua test.qmd
```
local remove
readMeta = function(meta)
remove = pandoc.utils.stringify(meta['lang-out'])
return meta
end
processDiv = function(el)
if remove and el.attributes["when-lang"] == remove then
return {}
else
return el.content
end
end
processCode = function(el)
if remove and el.classes and el.classes:includes("{"..remove .."}") then
return {}
end
return el
end
return {
{Meta = readMeta},
{Div = processDiv, CodeBlock = processCode}
}
---
title: "Untitled"
format: html
lang-out: r
---
# Slide
::: {when-lang=r}
Content
:::
``` {r}
1 + 1
````
See `{{< fa pen >}}`{=markdown}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment