From bc209420fe6e2b80654de7dfb931bdc1e1165e74 Mon Sep 17 00:00:00 2001 From: Bastien Dumont Date: Sat, 5 Nov 2022 19:35:43 +0100 Subject: [PATCH] =?UTF-8?q?Impl=C3=A9mentation=20du=20support=20pour=20des?= =?UTF-8?q?=20types=20arbitraires=20pour=20LaTeX=20et=20ConTeXt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- text-crossrefs.lua | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/text-crossrefs.lua b/text-crossrefs.lua index 8f8b73b..d17a15d 100644 --- a/text-crossrefs.lua +++ b/text-crossrefs.lua @@ -3,6 +3,7 @@ local stringify = pandoc.utils.stringify local TEXT_CROSSREF_CLASS = 'tcrf' local REF_TYPE_ATTR = 'reftype' local PREFIXED_ATTR = 'prefixref' +local IS_CONFIG_ARRAY = { ['additional_types'] = true } local RAW_ATTRIBUTE -- ConTeXt-specific tweak in order to add the label to the footnote @@ -94,7 +95,8 @@ local config = { default_reftype = 'page', default_prefixref = 'yes', filelabel_ref_separator = '::', - range_delim_tcrfenum = ' to ' + range_delim_tcrfenum = ' to ', + additional_types = {} } local accepted_types = { @@ -122,8 +124,16 @@ end local function set_configuration_item_from_metadata(item, metamap) metakey = 'tcrf-' .. string.gsub(item, '_', '-') if metamap[metakey] then - -- The metadata values are Str in MetaInlines. - config[item] = metamap[metakey][1].text + if IS_CONFIG_ARRAY[item] then + -- The metadata values is a list of MetaInlines, + -- each of them contains a single Str. + for _, value_metalist in ipairs(metamap[metakey]) do + table.insert(config[item], value_metalist[1].text) + end + else + -- The metadata value is a single Str in a MetaInlines. + config[item] = metamap[metakey][1].text + end end end @@ -136,6 +146,11 @@ local function configure(metadata) if RAW_ATTRIBUTE == 'openxml' then format_config_to_openxml() end + if RAW_ATTRIBUTE == 'context' or RAW_ATTRIBUTE == 'latex' then + for _, additional_type in ipairs(config.additional_types) do + accepted_types[additional_type] = true + end + end end -- End of configuration @@ -342,7 +357,7 @@ end local function get_ref_type(span) local ref_type = span.attributes[REF_TYPE_ATTR] or config.default_reftype if not accepted_types[ref_type] then - error_on_attr(REF_TYPE_ATTR, ref_type_attr_value, span.content) + error_on_attr(REF_TYPE_ATTR, ref_type, span.content) end return ref_type end