text-crossrefs: authorize spaces in metadata values

This commit is contained in:
Bastien Dumont
2025-12-21 22:41:34 +01:00
parent 0c7feaf2dd
commit e2ae4c3722
3 changed files with 9 additions and 10 deletions

View File

@ -263,10 +263,10 @@ and should be collapsed by the macro when it is desirable:
# Customization
Most of the customization variables expect a string.
In this case, they must not contain Markdown markup
and all breakable spaces must be replaced with the HTML entity ` `:
otherwise, only the first word is taken into account and leading and trailing spaces are ignored.
See `sample-with-options.md` for examples.
In this case, all Markdown markup will be ignored.
To prevent leading and trailing spaces to be stripped by Pandoc,
they must be replaced with HTML entities (` `):
see `sample-with-options.md` for examples.
## Common options {#common-opts}

View File

@ -13,7 +13,7 @@ tcrf-pagenote-first-type: note
tcrf-range-separator: '-'
tcrf-references-enum-separator: ';'
tcrf-multiple-delimiter: '; '
tcrf-multiple-before-last: '; and '
tcrf-multiple-before-last: '; and '
tcrf-additional-types:
- line
tcrf-range-delim-crossrefenum: '\>'

View File

@ -136,18 +136,17 @@ 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,
-- each of them contains a single Str.
-- The metadata values is a list of MetaInlines.
for _, value_metalist in ipairs(metamap[metakey]) do
table.insert(config[item], value_metalist[1].text)
table.insert(config[item], stringify(value_metalist))
end
else
local value = metamap[metakey]
if type(value) == 'boolean' then
config[item] = value
else
-- The metadata value is a single Str in a MetaInlines.
config[item] = value[1].text
-- The metadata value is a MetaInlines.
config[item] = stringify(value)
end
end
end