Skip to content

Commit 2a36300

Browse files
committed
latex,custom crossrefs - warn instead of crash when missing fields. Closes #10816
1 parent 2d29878 commit 2a36300

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/resources/filters/crossref/custom.lua

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,26 @@ function initialize_custom_crossref_categories(meta)
7070
local function as_latex(inlines)
7171
return trim(pandoc.write(pandoc.Pandoc(inlines), "latex"))
7272
end
73+
local function emit_warning(msg)
74+
warn(msg)
75+
quarto.log.output(entry)
76+
warn("Compilation will continue, but the output is likely going to be incorrect.")
77+
end
7378
metaInjectLatex(meta, function(inject)
79+
local ref_type = entry["key"]
80+
if ref_type == nil then
81+
emit_warning("field 'key' is required for custom crossref environments, but is missing for the following entry:")
82+
return
83+
end
7484
local env_name = entry["latex-env"]
85+
if env_name == nil then
86+
emit_warning("field 'latex-env' is required for custom crossref environments, but is missing for the following entry:")
87+
end
7588
local name = entry["reference-prefix"]
7689
local env_prefix = entry["caption-prefix"] or name
77-
local ref_type = entry["key"]
90+
if env_prefix == nil then
91+
emit_warning("fields 'caption-prefix' or 'reference-prefix' are required for custom crossref environments, but are missing for the following entry:")
92+
end
7893
local list_of_name = entry["latex-list-of-file-extension"] or ("lo" .. ref_type)
7994
local list_of_description = entry["latex-list-of-description"] or name
8095
local cap_location = entry["caption-location"] or "bottom"

0 commit comments

Comments
 (0)