Replies: 4 comments
-
Currently, that's the "best way". You can find several discussions and proposals for a way to set a "initial" script loaded for all subsequent code cells. |
Beta Was this translation helpful? Give feedback.
-
You would need to run python from Lua which is not ideal. Possibly you could look at partials extension which is basically a templated include : https://github.com/gadenbuie/quarto-partials This way you could do
but honestly I don't think this is easier than just sourcing your python function for the .qmd and then use in a cells as you are doing now. Not that verbose to me. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the recommendations. I'll work with what I have already! |
Beta Was this translation helpful? Give feedback.
-
This is a reminder that, in this repo, parroting LLM output is a violation of our code of conduct and we enforce it strictly. |
Beta Was this translation helpful? Give feedback.
-
Description
I wrote a python function
list_dir
that outputs html code for the contents of a local directory.Presently I use it in
.qmd
documents as follows (list_dir.qmd
contains the Python function declaration - tell me if you want me to post it):This works fine, but is a bit verbose. What's the best way to streamline this?
I tried writing a shortcode, but e.g.
simply renders the unevaluated code in the output and I could not figure the correct
pandoc
function to use instead or if it even exists.Presumably the python code could be re-written in lua (but I'm not familiar with that language).
Beta Was this translation helpful? Give feedback.
All reactions