-
I'm outputting my qmd in GFM, which puts code and output adjacent to each other. I would like to wrap only the code in a I tried this:
But this also puts the output (in this case, a plot) into the details section. I couldn't find an option for that in the GFM docs. My hunch is that I need to write a filter, function CodeBlock(code_block)
if code_block.attributes["code-fold"] == "true" then
local open = "<details><summary>Code </summary>\n"
local close = "\n</details>"
local open_block = pandoc.RawBlock("html", open)
local close_block = pandoc.RawBlock("html", close)
return {open_block, code_block, close_block}
end
return code_block
end Is that the right approach? (NB: I'm aware that HTML output does this. But I need to output to GFM where there is no collapse option.) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
In my opinion, "the right approach" would be for Quarto to handle this natively. Reusable chunk is another way (probably the easiest) for R code cells.
To note and as pointed out,
|
Beta Was this translation helpful? Give feedback.
In my opinion, "the right approach" would be for Quarto to handle this natively.
Reusable chunk is another way (probably the easiest) for R code cells.
To note and as pointed out,
code-fold: true
will do the same thing as above but for html-based formats.Possibly a feature request (#2279) to extend that option to other formats such as
gfm
.