Lua Environment

The Pandoc and Quarto Lua objects, as document metadata.

What the lua-env extension is for, how to enable it, and the smallest shortcode that prints a value from the render environment.

Quarto and Pandoc keep a good deal of state about a render: which format is being written, which file is being read, which version is running, what the reader and writer options are. All of it is reachable from a Lua filter, and none of it from the document you are writing.

lua-env copies that state into the document’s metadata. Once it has run, a value from the render environment can be printed with a shortcode, the same way any other metadata is, and optionally written out as JSON.

Installation

quarto add mcanouil/quarto-lua-env@1.6.0

This will install the extension under the _extensions subdirectory. If you are using version control, you will want to check in this directory.

Or install it from your editor with Quarto Wizard:

Quick start

The filter has to be enabled before the shortcode has anything to read:

filters:
  - lua-env

Then name a value by its dot-separated path:

{{< lua-env pandoc.FORMAT >}}

This page renders to html, under Pandoc 3.10.

The same values are reachable through Quarto’s own meta shortcode, under the lua-env key:

{{< meta lua-env.pandoc.FORMAT >}}

See the Reference for every option and every path, and the Examples for values printed live.

Where it works

Every output format. The values differ by format, which is rather the point: pandoc.FORMAT is html here and latex in a PDF.

Back to top