Skip to content

Commit e42283d

Browse files
committed
docs: warn about match() returning false not nil in filter rules
quarto.utils.match() returns false on no-match, not nil. Using == nil lets the boolean slip through to Pandoc constructors.
1 parent 10da1f7 commit e42283d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎.claude/rules/filters/lua-development.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ quarto.utils.match("[1]/{Plain}")(content)
107107
quarto.utils.match(".cell-output-display/:child/{Para}")(div)
108108
```
109109

110+
**Return value:** `match()` returns the matched node on success, `false` (not `nil`) on no-match. As a boolean guard this is fine (`false` is falsy). But when using the result as an element, check `if not result` — never `if result == nil`, which lets `false` through to Pandoc constructors ("Inline-ish expected, got boolean").
111+
110112
Prefer `match()` over manual `.content[1].t ==` checks — it's nil-safe, readable, and already used in 20+ filter callsites.
111113

112114
### Slot Assignment

0 commit comments

Comments
 (0)