diff --git a/text-crossrefs.lua b/text-crossrefs.lua
index ac7201f..d9f631f 100644
--- a/text-crossrefs.lua
+++ b/text-crossrefs.lua
@@ -21,28 +21,13 @@ local RAW_ATTRIBUTE
and redefine the macro so that it takes it into account.
]]--
-local function tweak_footnote_if_ConTeXt(metadata)
+local function support_footnote_label_ConTeXt(metadata)
if RAW_ATTRIBUTE == 'context' then
- local footnote_redefinition = [[
-\catcode`\@=11
-\let\origfootnote\footnote
-\def\footnote#1#2{
- \def\tcrf@secondArg{#2}%
- \def\tcrf@bracket{[}%
- \ifx\tcrf@secondArg\tcrf@bracket
- \def\tcrf@todo{\tcrf@footnote@withlabel{#1}#2} %
- \else
- \def\tcrf@todo{\origfootnote{#1}#2}%
- \fi
- \tcrf@todo
-}
-\def\tcrf@footnote@withlabel#1[#2]{\origfootnote[#2]{#1}}
-\catcode`\@=13
- ]]
+ local label_macro_def = '\n\\def\\withfirstopt[#1]#2{#2[#1]}\n'
if not metadata['header-includes'] then
metadata['header-includes'] = pandoc.MetaBlocks(pandoc.RawBlock('context', ''))
end
- metadata['header-includes']:insert(pandoc.RawBlock('context', footnote_redefinition))
+ metadata['header-includes']:insert(pandoc.RawBlock('context', label_macro_def))
end
return metadata
end
@@ -254,20 +239,20 @@ local collect_note_labels = {
local function make_notelabel(pos)
-- About the strategy followed with ConTeXt,
- -- see above tweak_footnote_if_ConTeXt.
+ -- see above support_footnote_label_ConTeXt.
local raw_code = ''
if pos == 'begin' then
if RAW_ATTRIBUTE == 'openxml' then
raw_code = string.gsub(
'',
'{{label}}', current_note_labels[1])
+ elseif RAW_ATTRIBUTE == 'context' then
+ raw_code = '\\withfirstopt[note:' .. current_note_labels[1] .. ']'
end
elseif pos == 'end' then
if RAW_ATTRIBUTE == 'openxml' then
raw_code = string.gsub('',
'{{label}}', current_note_labels[1])
- elseif RAW_ATTRIBUTE == 'context' then
- raw_code = '[note:' .. current_note_labels[1] .. ']'
end
end
return pandoc.RawInline(RAW_ATTRIBUTE, raw_code)
@@ -617,7 +602,7 @@ end
return {
{ Meta = configure },
- { Meta = tweak_footnote_if_ConTeXt },
+ { Meta = support_footnote_label_ConTeXt },
{ Note = set_notelabels },
{ Note = map_spans_to_notelabels },
{ Span = control_label_placement },