text-crossrefs: required escapes in Typst
This commit is contained in:
@ -132,13 +132,22 @@ local function format_config_to_openxml()
|
||||
end
|
||||
end
|
||||
|
||||
local function typst_escape(s, k)
|
||||
if FORMAT == 'typst' and k ~= 'tcrf-references-enum-separator'
|
||||
and k ~= 'tcrf-range-delim-crossrefenum'
|
||||
then
|
||||
s = string.gsub(s, '^([;#])', '#"%1"')
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
local function set_configuration_item_from_metadata(item, metamap)
|
||||
local metakey = 'tcrf-' .. string.gsub(item, '_', '-')
|
||||
if metamap[metakey] then
|
||||
if IS_CONFIG_ARRAY[item] then
|
||||
-- The metadata values is a list of MetaInlines.
|
||||
for _, value_metalist in ipairs(metamap[metakey]) do
|
||||
table.insert(config[item], stringify(value_metalist))
|
||||
table.insert(config[item], typst_escape(stringify(value_metalist), metakey))
|
||||
end
|
||||
else
|
||||
local value = metamap[metakey]
|
||||
@ -146,7 +155,7 @@ local function set_configuration_item_from_metadata(item, metamap)
|
||||
config[item] = value
|
||||
else
|
||||
-- The metadata value is a MetaInlines.
|
||||
config[item] = stringify(value)
|
||||
config[item] = typst_escape(stringify(value), metakey)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user