Quarto [shortcodes](https://quarto.org/docs/authoring/shortcodes.html) are a powerful, yet non-standard, extension to pandoc markdown syntax. Having them separated as reusabe lua filter, located at https://github.com/pandoc/lua-filters or in a separate git repository would allow to use this feature independently from Quarto and help to agree on common markdown extensions instead of every tool having its own extensions. The current implementation is [somwhere in the Quarto sources](https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/filters/quarto-pre/shortcodes.lua). I managed to use it with a Quarto installation this way:

~~~bash
#!/bin/bash
export QUARTO_FILTER_PARAMS=$(echo '{"results-file":"tmp.html"}' | base64)
FILTER=/opt/quarto/share/filters/quarto-pre/quarto-pre.lua
INPUT='{{< pagebreak >}} {{< meta title >}}'
pandoc -L $FILTER <(echo "$INPUT") -M title=test
~~~

result:

~~~html
<p><div style="page-break-after: always;"></div> test</p>
~~~

This use is obviously fragile. I would welcome an official release of shortcodes as lua filter. I guess that it's enough to combine `shortcodes.lua` and `shortcodes-handlers.lua` and to provide an alternative to lua [function call param](https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/filters/quarto-pre/shortcodes-handlers.lua#L68) to get the the list of custom shortcode files (could be a document meta variable or an environment variable such as `FILTER_SHORTCODES`). Sure I could just copy and adjust the code and add it to [lua-filters](https://github.com/pandoc/lua-filters) but then shortcodes feature is forked and with further evolution of Quarto we likely have two slightly differing sets and types of shortcodes.

**tl;dr:** it makes sense to reuse shortcodes independently from Quarto but this should be made easy and stable. 



2022-05-17T07:04:34Z
nichtich
closed
Factor out shortcodes as pandoc-filter
https://github.com/quarto-dev/quarto-cli/issues/904