Skip to content

Fix inverted logic in quarto.utils.is_empty_node for text nodes#14297

Open
cderv wants to merge 2 commits intomainfrom
fix/is-empty-node-inverted-logic
Open

Fix inverted logic in quarto.utils.is_empty_node for text nodes#14297
cderv wants to merge 2 commits intomainfrom
fix/is-empty-node-inverted-logic

Conversation

@cderv
Copy link
Copy Markdown
Collaborator

@cderv cderv commented Apr 1, 2026

When calling quarto.utils.is_empty_node() on text nodes like Str, Code, or RawInline, the function returns inverted results: true for non-empty nodes and false for empty ones.

Root Cause

The .text branch in is_empty_node used node.text ~= '' (not-equal) instead of node.text == '' (equal). Every other branch follows the pattern of returning true when the node has no content — for example, not next(node.content) returns true when the content list is empty. The text branch should follow the same semantics: Str('') is empty just as Para({}) is empty — a node of the right type with nothing in it.

Fix

Change the operator from ~= to == so text nodes follow the same emptiness semantics as container nodes.

Internal callers all pass container nodes (captions, preambles) so nothing was visibly broken, but extension authors calling the public API on text nodes get wrong results.

cderv added 2 commits April 1, 2026 17:35
The text branch (`node.text`) used `~=` (not-equal) where it should
use `==` (equal), causing is_empty_node to return true for non-empty
text nodes and false for empty ones.

Text nodes like Str and Code should follow the same emptiness
semantics as container nodes like Para and Div: a Str('') is empty
just as Para({}) is empty -- a node of the right type but with
nothing in it.

Internal callers all pass container nodes (caption, preamble) so
nothing was visibly broken, but extension authors calling the public
API on text nodes get wrong results.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant