Skip to content

Better error when unknown id is used on callout in typst #13589

@cderv

Description

@cderv
---
title: "Callout error"
format: typst
---

## Callouts 

::: {#random-id .callout-note}

## Note 
This is a note callout 

:::

It does not error nicely

Error running filter C:/Users/chris/Documents/DEV_R/quarto-cli/src/resources/filters/main.lua:
...arto-cli/src/resources/filters/./customnodes/callout.lua:308: attempt to index a nil value (local 'category')
stack traceback:
        .../DEV_R/quarto-cli/src/resources/filters/./ast/render.lua:46: in local 'filter_fn'
        ...R/quarto-cli/src/resources/filters/./ast/customnodes.lua:168: in function <...R/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'
        ...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...)
        ...R/quarto-cli/src/resources/filters/./ast/customnodes.lua:87: in function <...R/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:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render-files.ts:361:11)
    at eventLoopTick (ext:core/01_core.js:179:7)
    at async render (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/command/render/render-shared.ts:104:18)
    at async Command.actionHandler (file:///C:/Users/chris/Documents/DEV_R/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:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/quarto.ts:193:5)
    at async file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/quarto.ts:225:5
    at async file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/core/main.ts:45:14
    at async mainRunner (file:///C:/Users/chris/Documents/DEV_R/quarto-cli/src/core/main.ts:47:5)

This is because we are expecting the id to be a category and we don't handle nil

local category = crossref.categories.by_ref_type[refType(callout.attr.identifier)]
return make_typst_figure {
content = typst_callout,
caption_location = "top",
caption = pandoc.Plain(pandoc.Str("")),
kind = "quarto-callout-" .. _quarto.modules.callouts.displayName(callout.type),
supplement = param("crossref-" .. callout.type .. "-prefix") or category.name,
numbering = "1",
identifier = callout.attr.identifier
}
end)

Metadata

Metadata

Assignees

Labels

calloutsIssues with Callout Blocks.enhancementNew feature or requesttypst

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions