Return a CodeBlock
from a custom shortcode
#12791
Unanswered
albertomercurio
asked this question in
Q&A
Replies: 2 comments 5 replies
-
Running your code is responsibility of the engines, which run before Lua filters. This order is fixed and by design, because the majority of the use cases for filters involves post-processing of the execution results. Unfortunately, that means that what you're looking to do simply isn't something that Quarto is well-equipped to let you do. The best alternative I can think of is for you to have a pre-render script that generates your qmd from code. It's not going to be particularly nice, but I don't think there's an easy way around it. |
Beta Was this translation helpful? Give feedback.
3 replies
This comment has been hidden.
This comment has been hidden.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
Hello,
I'm trying to make a custom shortcode that extends the capabilities of the built-in
include
shortcode, to also support labels of code blocks.For example, I can have a file called
somefile.qmd
with the contentAnd a file called
example.qmd
withSuch that only the code block is included.
I know there is the
embed
shortcode that does a similar thing, but here I want the code to be run from the current file, and not from the external one. For the moment theembed
shortcode has several limitations.The Lua code
In my lua code, I'm able to parse all the blocks with
and also to identify the block with the desired label
However, when I render the
example.qmd
file, quarto correctly shows the code block, but doesn't run it. I think that quarto renders the block as a plain block.👉🏼 Link of the repo of the extension
Beta Was this translation helpful? Give feedback.
All reactions