Last active
May 30, 2023 12:12
-
-
Save cderv/9b7049780f75fb2c0e370a6aaa1feef3 to your computer and use it in GitHub Desktop.
Get some component out of a Qmd document
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* 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 | |
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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