From f61248278f3ee07b97dbce80b56c7cafc633ea82 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 13 Sep 2010 18:14:52 +0200 Subject: =?UTF-8?q?so=20called=20=E2=80=9Ccitation=20references=E2=80=9D?= =?UTF-8?q?=20(stub);=20inline=20markup=20in=20footnotes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rst_context.lua | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'rst_context.lua') diff --git a/rst_context.lua b/rst_context.lua index 5c36c54..575d756 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -74,6 +74,14 @@ function rst_context.footnote_reference (label) print("creating symbolnote nr " .. rc) rst_context.current_symbolnote_number = rc return [[\\symbolnote{\\getbuffer[__footnote_symbol_]].. rc .."]}" + else -- “citation reference” for now treating them like footnotes + local rc = rst_context.current_footnote_number + rc = rc + 1 + --rst_context.current_footnote_number = rst_context.current_footnote_number + 1 + print("creating footnote nr " .. rc) + rst_context.current_footnote_number = rc + return [[\\footnote{\\getbuffer[__footnote_number_]].. rc .."]}" + --return [[\\cite{]] .. label .. "}" end end @@ -316,7 +324,10 @@ local inline_parser = P{ _reference = (1 - V"underscore" - V"spacing" - V"eol" - V"punctuation" - V"groupchars")^1 * V"underscore", - footnote_reference = V"lsquare" * Cs(V"footnote_label") * V"rsquare" * V"underscore" + footnote_reference = V"lsquare" + * Cs(V"footnote_label" + V"citation_reference_label") + * V"rsquare" + * V"underscore" / rst_context.footnote_reference , @@ -326,6 +337,8 @@ local inline_parser = P{ + V"asterisk" , + citation_reference_label = V"letter" * (1 - V"rsquare")^1, + -------------------------------------------------------------------------------- -- Urls -------------------------------------------------------------------------------- @@ -866,18 +879,23 @@ function rst_context.footnote(label, content) local tf = state.footnotes rst_context.addsetups("footnotes") if label:match("^%d+$") then -- all digits - tf.numbered[tonumber(label)] = content + tf.numbered[tonumber(label)] = rst_context.escape(inline_parser:match(content)) elseif label == "#" then --autonumber repeat -- until next unrequested number tf.autonumber = tf.autonumber + 1 until tf.numbered[tf.autonumber] == nil - tf.numbered[tf.autonumber] = content + tf.numbered[tf.autonumber] = rst_context.escape(inline_parser:match(content)) elseif label:match("^#.+$") then local thelabel = label:match("^#(.+)$") - tf.autolabel[thelabel] = content + tf.autolabel[thelabel] = rst_context.escape(inline_parser:match(content)) elseif label == "*" then rst_context.addsetups("footnote_symbol") - tf.symbol[#tf.symbol+1] = content + tf.symbol[#tf.symbol+1] = rst_context.escape(inline_parser:match(content)) + else -- “citation reference” treated like ordinary footnote + repeat -- until next unrequested number + tf.autonumber = tf.autonumber + 1 + until tf.numbered[tf.autonumber] == nil + tf.numbered[tf.autonumber] = rst_context.escape(inline_parser:match(content)) end return "" end -- cgit v1.2.3