Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/changelog-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
- Add support for relative paths in `require()` calls.
- ([#5242](https://github.com/quarto-dev/quarto-cli/issues/5242)): Add line numbers to error messages.
- Add support `quarto.doc.add_resource` and `quarto.doc.add_supporting`. `add_resource` will add a resource file to the current render, copying that file to the same relative location in the output directory. `add_supporting` will add a supporting file to the current render, moving that file file to the same relative location in the output directory.
- ([#6211](https://github.com/quarto-dev/quarto-cli/pull/6211)): Improve error message when a JSON filter (or a potentially misspelled Lua filter from an extension) is not found.

## Books

Expand Down
16 changes: 15 additions & 1 deletion src/resources/filters/common/wrapped-filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,21 @@ function makeWrappedJsonFilter(scriptFile, filterHandler)
return meta
end
})
local result = pandoc.utils.run_json_filter(doc, path)
local success, result = pcall(pandoc.utils.run_json_filter, doc, path)
if not success then
local pandoc_error = tostring(result)
local filename = pandoc.path.filename(path)
local message = {
"Could not run " .. path .. " as a JSON filter.",
"Please make sure the file exists and is executable.",
"\nDid you intend '" .. filename .. "' as a Lua filter in an extension?",
"If so, make sure you've spelled the name of the extension correctly.",
"\nThe original Pandoc error follows below.",
pandoc_error
}
fail(table.concat(message, "\n"))
return nil
end
if has_custom_nodes then
doc:walk({
Meta = function(meta)
Expand Down