Skip to content

Conversation

@cderv
Copy link
Collaborator

@cderv cderv commented Oct 28, 2025

ConditionalBlock in manuscript projects would crash with a fatal error during rendering when using conditional content like .content-visible when-format.

Summary below, more details in

Root Cause

The manuscript filter built block collections using pandoc.List() and assigned them to divEl.content. This changed the content type from "Blocks" to "List". When ConditionalBlock's render function returned el.content, it returned a List without a .walk() method.

During custom node rendering, has_custom_nodes() attempts to walk the rendered result to check for nested custom nodes. The AST walker's checked_walk() function expects walkable Pandoc elements (Blocks, Inlines, Pandoc) and fails on plain Lua tables like List. This guard rail correctly caught the type mismatch.

Why Manuscript Specifically?

Default projects don't run the manuscript filter, so Div.content remains type "Blocks" throughout. Only manuscript's flattening logic (which builds new block collections) exposed this type mismatch issue.

Fix

Changed manuscript.lua to use pandoc.Blocks({}) instead of pandoc.List() to maintain proper type throughout the filter chain.

Fixes #13616

A note that this bug was introduced in 1.7 and it was not failing in 1.6. So maybe we should consider backport... 🤔

cderv added 3 commits October 28, 2025 11:42
In manuscript.lua, using pandoc.List() to build block collections and assigning to divEl.content changed the content type from "Blocks" to "List". When ConditionalBlock returned el.content, it returned a List without a .walk() method, causing crashes during AST traversal. Changed to pandoc.Blocks({}) to maintain proper type throughout the filter chain.

Fixes #13616
@posit-snyk-bot
Copy link
Collaborator

posit-snyk-bot commented Oct 28, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Licenses 0 0 0 0 0 issues
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

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.

Custom Blocks Div like Conditional Blocks are throwing fatal error in Manuscript project

3 participants