Skip to content

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

@mcanouil

Description

@mcanouil

I have

  • searched the issue tracker for similar issues
  • installed the latest version of Quarto CLI
  • formatted my issue following the Bug Reports guide

Bug description

Tangentially to #14562, I discovered another issue involving when-format="llms-txt" and shortcodes resolution.

In a website project with llms-txt: true, placing any shortcode inside a conditional content block keyed on llms-txt (for example ::: {.content-visible when-format="llms-txt"}) aborts the render with a fatal internal error instead of producing output.

Root cause (confirmed from the filter pipeline):

  1. Shortcodes are expanded by pre-shortcodes-filter in the pre phase.
  2. pre-llms-conditional-content runs afterwards, in the same pre phase.
    When a ConditionalBlock references llms-txt and its llms visibility differs from its HTML visibility, the handler rebuilds the block from tbl.original_node:clone().
  3. original_node is the snapshot captured at parse time, before shortcode expansion, so the clone re-injects the original unexpanded shortcode into the document after expansion has already run. Nothing expands it again.
  4. The leftover Shortcode custom node reaches the post-phase custom-node render, whose render for Shortcode is a placeholder that calls internal_error(), aborting the render.

Source references (permalinks at commit 5748ba2):

Steps to reproduce

_quarto.yml:

project:
  type: website
website:
  title: "llms-txt repro"
  llms-txt: true
format:
  html:
    toc: true

index.qmd:

---
title: "Home"
---

::: {.content-visible when-format="llms-txt"}

## Conditional Section

{{< lipsum >}}

:::

Render the project:

quarto render

Actual behavior

The render aborts with a fatal internal error:

{
  __quarto_custom_node: Span {
    attr: Attr {
      attributes: AttributeList {
        __quarto_custom: "true"
        __quarto_custom_context: "Inline"
        __quarto_custom_id: "1"
        __quarto_custom_type: "Shortcode"
      }
      classes: List {}
      clone: function: 0xa68c3e730
      identifier: ""
    }
    clone: function: 0xa68c3e4c0
    content: Inlines {}
    walk: function: 0xa68c3e490
  }
  name: "lipsum"
  params: List {}
  t: "Shortcode"
  unparsed_content: "{{< lipsum >}}"
}
FATAL (/Users/mcanouil/Projects/quarto-dev/quarto-cli/src/resources/filters/./customnodes/shortcodes.lua:97) An error occurred:
This is an internal error. Please file a bug report at https://github.com/quarto-dev/quarto-cli/
Error running filter /Users/mcanouil/Projects/quarto-dev/quarto-cli/src/resources/filters/main.lua:
...to-dev/quarto-cli/src/resources/filters/./ast/render.lua:53: FATAL QUARTO ERROR
stack traceback:
        ...to-dev/quarto-cli/src/resources/filters/./common/log.lua:34: in function 'fatal'
        ...-dev/quarto-cli/src/resources/filters/./common/error.lua:14: in function 'fail'
        ...-dev/quarto-cli/src/resources/filters/./common/error.lua:19: in function 'internal_error'
        ...o-cli/src/resources/filters/./customnodes/shortcodes.lua:97: in field 'render'
        ...to-dev/quarto-cli/src/resources/filters/./ast/render.lua:53: in local 'filter_fn'
        ...v/quarto-cli/src/resources/filters/./ast/customnodes.lua:168: in function <...v/quarto-cli/src/resources/filters/./ast/customnodes.lua:158>
        (...tail calls...)
        ...c/resources/pandoc/datadir/../../filters/modules/jog.lua:34: in upvalue 'run_filter_function'
        ...c/resources/pandoc/datadir/../../filters/modules/jog.lua:223: in function <...c/resources/pandoc/datadir/../../filters/modules/jog.lua:202>
        (...tail calls...)
        [C]: in function 'tmap'
        ...c/resources/pandoc/datadir/../../filters/modules/jog.lua:125: in upvalue 'recurse'
        ...     (skipping 5 levels)
        ...c/resources/pandoc/datadir/../../filters/modules/jog.lua:98: in upvalue 'recurse'
        ...c/resources/pandoc/datadir/../../filters/modules/jog.lua:222: in function <...c/resources/pandoc/datadir/../../filters/modules/jog.lua:202>
        (...tail calls...)
        [C]: in function 'tmap'
        ...c/resources/pandoc/datadir/../../filters/modules/jog.lua:125: in upvalue 'recurse'
        ...c/resources/pandoc/datadir/../../filters/modules/jog.lua:222: in local 'jogger'
        ...c/resources/pandoc/datadir/../../filters/modules/jog.lua:171: in upvalue 'recurse'
        ...c/resources/pandoc/datadir/../../filters/modules/jog.lua:222: in function <...c/resources/pandoc/datadir/../../filters/modules/jog.lua:202>
        (...tail calls...)
        ...v/quarto-cli/src/resources/filters/./ast/customnodes.lua:87: in function <...v/quarto-cli/src/resources/filters/./ast/customnodes.lua:65>
        (...tail calls...)
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:82: in local 'callback'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:100: in upvalue 'run_emulated_filter_chain'
        .../quarto-cli/src/resources/filters/./ast/runemulation.lua:136: in function <.../quarto-cli/src/resources/filters/./ast/runemulation.lua:133>
WARN: Error encountered when rendering files
ERROR: Error
    at renderFiles (file:///Users/mcanouil/Projects/quarto-dev/quarto-cli/src/command/render/render-files.ts:360:11)
    at async renderProject (file:///Users/mcanouil/Projects/quarto-dev/quarto-cli/src/command/render/project.ts:439:23)
    at async Command.actionHandler (file:///Users/mcanouil/Projects/quarto-dev/quarto-cli/src/command/render/cmd.ts:251:26)
    at async Command.execute (https://deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts:1948:7)
    at async Command.parseCommand (https://deno.land/x/cliffy@v1.0.0-rc.3/command/command.ts:1780:14)
    at async quarto (file:///Users/mcanouil/Projects/quarto-dev/quarto-cli/src/quarto.ts:198:5)
    at async file:///Users/mcanouil/Projects/quarto-dev/quarto-cli/src/quarto.ts:231:5
    at async file:///Users/mcanouil/Projects/quarto-dev/quarto-cli/src/core/main.ts:45:14
    at async mainRunner (file:///Users/mcanouil/Projects/quarto-dev/quarto-cli/src/core/main.ts:47:5)
    at async file:///Users/mcanouil/Projects/quarto-dev/quarto-cli/src/quarto.ts:221:3

No HTML output is produced.

Expected behavior

The shortcode inside the conditional block is expanded, and the project renders successfully, the
same as when the shortcode sits outside the block or when llms-txt is not enabled.

Your environment

  • IDE: VSCode.
  • OS: macOS (Darwin 25.5.0).
  • Quarto: 99.9.9 (local development build from source, commit 5748ba2).

Quarto check output

Quarto 99.9.9
[✓] Checking environment information...
      Quarto cache location: /Users/mcanouil/Library/Caches/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.8.3: OK
      Dart Sass version 1.87.0: OK
      Deno version 2.7.14: OK
      Typst version 0.14.2: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 99.9.9
      commit: 5748ba2eb171c4906ce124f5c61c3246045e44a7
      Path: /Users/mcanouil/Projects/quarto-dev/quarto-cli/package/dist/bin

[✓] Checking tools....................OK
      TinyTeX: v2026.05
      Chrome Headless Shell: (not installed)
      VeraPDF: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /Users/mcanouil/Library/TinyTeX/bin/universal-darwin
      Version: 2026

[✓] Checking Chrome Headless....................OK
      Using: Chrome from QUARTO_CHROMIUM
      Path: /Applications/Brave Browser.app/Contents/MacOS/Brave Browser

[✓] Checking basic markdown render....OK

(|) Checking R installation...........ℹ R version 4.6.0 (2026-04-24)
! Config '~/.Rprofile' was loaded!
[✓] Checking R installation...........OK
      Version: 4.6.0
      Path: /Library/Frameworks/R.framework/Resources
      LibPaths:
        - /Library/Frameworks/R.framework/Versions/4.6/Resources/library
      knitr: 1.51
      rmarkdown: 2.31

[✓] Checking Knitr engine render......OK

[✓] Checking Python 3 installation....OK
      Version: 3.14.5
      Path: /opt/homebrew/opt/python@3.14/bin/python3.14
      Jupyter: (None)

      Jupyter is not available in this Python installation.
      Install with python3 -m pip install jupyter

      There is an unactivated Python environment in .venv. Did you forget to activate it?

[✓] Checking Julia installation...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingllms-txtshortcodesissues related to shortcodes

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions