Open mcanouil opened 1 year ago
Yes, this is something we should do.
With that said, I'm all but certain that quarto does not want to advertise every single possible variable which is technically accessible via Lua. So, if we're going to do this (which I agree with you we should), then we first need to figure out what parts of the available Lua API are "blessed" for future use.
We need to do this anyway (in order to be able to truly resolve some questions about what's a bug, what's a regression, and what are the API entry points that we need to maintain for the future). But there's a lot of behind-the-scenes work involved in this, so please be aware that it might be a few months until we can start this part of the project.
No worries, in my Quarto extension, I do not advertise in depth what is exposed (because there are a lot). It's kind of a brute force extension to expose as much as possible without having to do the lookup/update at every API changes from Quarto or Pandoc.
It's kind of a brute force extension to expose as much as possible without having to do the lookup/update at every API changes from Quarto or Pandoc.
Right, and that makes total sense to do. I just wanted to clarify that if we make this an internal quarto thing, then we're suddenly exposing all of those "accidentally-available" bits.
Related discussion with a use case for this: https://github.com/quarto-dev/quarto-cli/discussions/5029
As originally discussed in #2249, here is a separate issue to discuss exposing LUA variables.
Currently, users do not have access to all LUA variables (from Quarto and Pandoc) which could be useful. With that in mind I wrote a LUA filter/shortcode (https://github.com/mcanouil/quarto-lua-env) to expose the following objects recursively, or at least the scalar variables.
Variables can be accessed using:
{{< lua-env pandoc.PANDOC_VERSION >}}
{{< meta lua-env.pandoc.PANDOC_VERSION >}}
{{< lua-env quarto.doc.input_file >}}
{{< meta lua-env.quarto.doc.input_file >}}
This could be integrated into Quarto if deemed useful to have such behaviour as exposing "all" LUA variables to shortcode for use in Quarto document and possibly in code cells in the future.