-
Notifications
You must be signed in to change notification settings - Fork 907
/
Copy pathast.qmd
34 lines (23 loc) · 1.41 KB
/
ast.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
---
title: Custom AST Nodes
search: false
---
{{< include /docs/_require-1.3.qmd >}}
## Overview
Quarto now supports custom AST nodes in Pandoc filters. This allows more flexibility in defining and using Lua filters.
We will slowly roll out more extensive changes of the AST, but currently, the following objects are custom AST nodes:
- [Callouts](custom-ast-nodes/callout.qmd)
- [Tabsets](custom-ast-nodes/tabset.qmd)
- [Conditional Blocks](custom-ast-nodes/conditional-block.qmd)
## Example: Callouts
In previous versions of Quarto, callouts would be represented directly as a div with a class starting with `callout`, and the contents laid out in a [particular way](/docs/authoring/callouts.qmd).
While *authoring* documents, this syntax remains unchanged. But when processing the document, the callout divs are now represented as a custom AST node, which can be processed directly in Lua filters. In Quarto 1.3, callouts can be captured in Lua filters more directly. For example, here is a filter that forces every callout to be of type "caution":
``` lua
function Callout(callout)
-- do something with the callout
callout.type = "caution"
-- note that custom AST nodes are passed by reference. You can
-- return the value if you choose, but you do not need to.
end
```
Finally, custom AST node constructors are available in the `quarto` object: `quarto.Callout`, `quarto.Tabset`, etc. See the pages above for details.