Skip to content

fix(llms): expand shortcodes inside llms-keyed conditional content#14567

Open
cderv wants to merge 2 commits into
mainfrom
fix/issue-14563
Open

fix(llms): expand shortcodes inside llms-keyed conditional content#14567
cderv wants to merge 2 commits into
mainfrom
fix/issue-14563

Conversation

@cderv
Copy link
Copy Markdown
Member

@cderv cderv commented Jun 1, 2026

When a shortcode appears inside a content-visible when-format="llms-txt" block (or any content-hidden/unless-format variant) in a website with llms-txt: true, rendering aborts with a fatal internal error.

Root Cause

content-hidden.lua snapshots original_node at parse time (before shortcode expansion) and clears the live node.content for html-hidden blocks — an intentional invariant from #4867. The llms-conditional-content.lua handler always resurrected original_node:clone() regardless of direction, re-injecting unexpanded Shortcode nodes. Those reached the post-phase render placeholder, which calls internal_error().

Fix

The handler now selects the content source per direction. For llms-only blocks (html-hidden), the live slot was cleared, so original_node is the only surviving copy; process_shortcodes() is called on the resurrected clone to expand shortcodes the main pass never saw. For html-only blocks (llms-hidden), the live slot already holds fully-processed content; tbl.node:clone() is used instead of the stale snapshot.

Fixes #14563

cderv added 2 commits June 1, 2026 12:38
…14563)

A shortcode placed inside a content-visible/content-hidden block keyed on
when-format/unless-format="llms-txt" aborted the render with a fatal internal
error. The llms pre-filter resurrected the conditional block's parse-time
snapshot (original_node), whose shortcodes were never expanded; for html-hidden
blocks the live slot had been cleared at parse, so the unexpanded snapshot was
the only surviving copy and the leftover Shortcode node reached the post-phase
render placeholder.

Select the content source per case: for llms-only blocks expand shortcodes on
the resurrected snapshot; for html-only blocks use the already-processed live
slot instead of the stale snapshot.
@posit-snyk-bot
Copy link
Copy Markdown
Collaborator

posit-snyk-bot commented Jun 1, 2026

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

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 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.

A shortcode inside content-visible/content-hidden when-format="llms-txt" raises an internal error (unexpanded Shortcode reaches render)

2 participants