@@ -12,15 +12,60 @@ Note that you should use `quarto.log.output()` instead of this function.
1212function quarto .utils .dump (value ) end
1313
1414--[[
15- Compute the absolute path to a file that is installed alongside the Lua script.
15+ Extended type function that returns Pandoc types with Quarto custom node awareness.
1616
17- This is useful for internal resources that your filter needs but should
17+ Returns `"CustomBlock"` for Quarto custom block nodes and `"CustomInline"` for
18+ custom inline nodes, otherwise delegates to `pandoc.utils.type()`.
19+ ]]
20+ --- @param value any Value to check
21+ --- @return string
22+ function quarto .utils .type (value ) end
23+
24+ quarto .utils .table = {}
25+
26+ --[[
27+ Return `true` if the table is a plain integer-indexed array.
28+ ]]
29+ --- @param t table Table to check
30+ --- @return boolean
31+ function quarto .utils .table .isarray (t ) end
32+
33+ --[[
34+ Return `true` if the array-like table contains the given value.
35+ ]]
36+ --- @param t table Array-like table to search
37+ --- @param value any Value to find
38+ --- @return boolean
39+ function quarto .utils .table .contains (t , value ) end
40+
41+ --[[
42+ Iterator that traverses table keys in sorted order.
43+ ]]
44+ --- @param t table Table to iterate
45+ --- @param f ? function Optional comparison function for sorting
46+ --- @return function Iterator function
47+ function quarto .utils .table .sortedPairs (t , f ) end
48+
49+ --[[
50+ Compute the absolute path to a file that is installed alongside the Lua script.
51+
52+ This is useful for internal resources that your filter needs but should
1853not be visible to the user.
1954]]
2055--- @param path string Path of file relative to the Lua script
2156--- @return string
2257function quarto .utils .resolve_path (path ) end
2358
59+ --[[
60+ Resolve a file path relative to the document's working directory.
61+
62+ Unlike `resolve_path()` which resolves relative to the Lua script,
63+ this resolves relative to the document being rendered.
64+ ]]
65+ --- @param path string File path to resolve
66+ --- @return string
67+ function quarto .utils .resolve_path_relative_to_document (path ) end
68+
2469--[[
2570Converts a string to a list of Pandoc Inlines, processing any Quarto custom
2671syntax in the string.
@@ -38,6 +83,78 @@ syntax in the string.
3883--- @return pandoc.Blocks
3984function quarto .utils .string_to_blocks (path ) end
4085
86+ --[[
87+ Coerce the given object into a `pandoc.Inlines` list.
88+
89+ Handles Inline, Inlines, Block, Blocks, List, and table inputs.
90+ More performant than `pandoc.Inlines()` as it avoids full marshal roundtrips.
91+
92+ Note: The input object may be modified destructively.
93+ ]]
94+ --- @param obj any Object to coerce
95+ --- @return pandoc.Inlines
96+ function quarto .utils .as_inlines (obj ) end
97+
98+ --[[
99+ Coerce the given object into a `pandoc.Blocks` list.
100+
101+ Handles Block, Blocks, Inline, Inlines, List, Caption, and table inputs.
102+ More performant than `pandoc.Blocks()` as it avoids full marshal roundtrips.
103+
104+ Note: The input object may be modified destructively.
105+ ]]
106+ --- @param obj any Object to coerce
107+ --- @return pandoc.Blocks
108+ function quarto .utils .as_blocks (obj ) end
109+
110+ --[[
111+ Return `true` if the given AST node is empty.
112+
113+ A node is considered empty if it's an empty list/table, has empty `content`,
114+ has empty `caption`, or has an empty `text` field.
115+ ]]
116+ --- @param node any AST node to check
117+ --- @return boolean
118+ function quarto .utils .is_empty_node (node ) end
119+
120+ --[[
121+ Walk and render extended/custom AST nodes.
122+
123+ Processes Quarto custom AST nodes (like Callout, Tabset, etc.) into their
124+ final Pandoc representation.
125+ ]]
126+ --- @param node pandoc.Node AST node to render
127+ --- @return pandoc.Node
128+ function quarto .utils .render (node ) end
129+
130+ --[[
131+ CSS-selector-like AST matcher for Pandoc nodes.
132+
133+ Accepts string path selectors separated by `/` with support for:
134+ - Element type selectors (e.g. `"Header"`, `"Para"`, `"Div"`)
135+ - Child traversal via `/` separator
136+ - `*` wildcard to match any child
137+ - `{Type}` capture syntax to return matched nodes
138+ - `:child` to search direct children
139+ - `:descendant` to search all descendants
140+ - `:nth-child(n)` to match a specific child index
141+
142+ Returns a function that, when called with an AST node, returns the matched
143+ node(s) or `false`/`nil` if no match.
144+ ]]
145+ --- @param ... string | function Selector path components
146+ --- @return function Matcher function
147+ function quarto .utils .match (...) end
148+
149+ --[[
150+ Append a Block, Blocks, or Inlines value to an existing Blocks list.
151+
152+ Inlines are wrapped in a Plain block before appending.
153+ ]]
154+ --- @param blocks pandoc.Blocks Target Blocks list
155+ --- @param block pandoc.Block | pandoc.Blocks | pandoc.Inlines Value to append
156+ function quarto .utils .add_to_blocks (blocks , block ) end
157+
41158--[[
42159Returns a filter that parses book metadata markers during document traversal.
43160
0 commit comments