Skip to content

Commit

Permalink
Provide global function quarto_assert
Browse files Browse the repository at this point in the history
This behaves mostly like the built-in `assert`, but respects the general
Quarto scaffolding.
  • Loading branch information
tarleb committed Nov 27, 2024
1 parent dcbcd22 commit 697a3da
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/resources/filters/ast/customnodes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,7 @@ _quarto.ast = {
end
local node = node_accessor(table)
local t = pandoc.utils.type(value)
-- FIXME this is broken; that can only be "Block", "Inline", etc
if t == "Div" or t == "Span" then
local custom_data, t, kind = _quarto.ast.resolve_custom_data(value)
if custom_data ~= nil then
value = custom_data
end
end
quarto_assert(t ~= 'Div' and t ~= 'Span', "")
if index > #node.content then
_quarto.ast.grow_scaffold(node, index)
end
Expand Down
11 changes: 9 additions & 2 deletions src/resources/filters/common/error.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ function fail(message, level)
end
end

function internal_error()
fail("This is an internal error. Please file a bug report at https://github.com/quarto-dev/quarto-cli/", 5)
function internal_error(msg, level)
fail((msg and (msg .. '\n') or '') ..
"This is an internal error. Please file a bug report at https://github.com/quarto-dev/quarto-cli/", level or 5)
end

function quarto_assert (test, msg, level)
if not test then
internal_error(msg, level or 6)
end
end

function currentFile()
Expand Down

0 comments on commit 697a3da

Please sign in to comment.