Skip to content

Fix ConditionalBlock crash in manuscript projects - #13624

Merged
cderv merged 4 commits into
mainfrom
fix/fatal-error-manuscript
Nov 12, 2025
Merged

cderv merged 4 commits into
mainfrom
fix/fatal-error-manuscript

Conversation

@cderv

@cderv cderv commented Oct 28, 2025 •

Copy link
Copy Markdown
Member

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... 🤔

@posit-snyk-bot

posit-snyk-bot commented Oct 28, 2025 •

Copy link
Copy Markdown
Collaborator

✅ 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.

@cderv
cderv force-pushed the fix/fatal-error-manuscript branch 2 times, most recently from 6e74c59 to 763f93e Compare November 12, 2025 10:05
cderv added a commit that referenced this pull request Nov 12, 2025
@cderv
cderv force-pushed the fix/fatal-error-manuscript branch from 763f93e to 22c25fa Compare November 12, 2025 10:26
cderv added a commit that referenced this pull request Nov 12, 2025
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
@cderv
cderv force-pushed the fix/fatal-error-manuscript branch from 317b3ff to 2a92052 Compare November 12, 2025 10:55
@cderv
cderv merged commit c76c0a3 into main Nov 12, 2025
2 checks passed
@cderv
cderv deleted the fix/fatal-error-manuscript branch November 12, 2025 10:58
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

2 participants