Skip to content

Commit 91b1c38

Browse files
committed
Provide global function quarto_assert
This behaves mostly like the built-in `assert`, but respects the general Quarto scaffolding.
1 parent cda6ebb commit 91b1c38

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/resources/filters/ast/customnodes.lua

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,7 @@ _quarto.ast = {
337337
end
338338
local node = node_accessor(table)
339339
local t = pandoc.utils.type(value)
340-
-- FIXME this is broken; that can only be "Block", "Inline", etc
341-
if t == "Div" or t == "Span" then
342-
local custom_data, t, kind = _quarto.ast.resolve_custom_data(value)
343-
if custom_data ~= nil then
344-
value = custom_data
345-
end
346-
end
340+
quarto_assert(t ~= 'Div' and t ~= 'Span', "")
347341
if index > #node.content then
348342
_quarto.ast.grow_scaffold(node, index)
349343
end

src/resources/filters/common/error.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@ function fail(message, level)
1515
end
1616
end
1717

18-
function internal_error()
19-
fail("This is an internal error. Please file a bug report at https://github.com/quarto-dev/quarto-cli/", 5)
18+
function internal_error(msg, level)
19+
fail((msg and (msg .. '\n') or '') ..
20+
"This is an internal error. Please file a bug report at https://github.com/quarto-dev/quarto-cli/", level or 5)
21+
end
22+
23+
function quarto_assert (test, msg, level)
24+
if not test then
25+
internal_error(msg, level or 6)
26+
end
2027
end
2128

2229
function currentFile()

0 commit comments

Comments
 (0)