summaryrefslogtreecommitdiff
path: root/rst_context.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-13 18:14:52 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-13 18:14:52 +0200
commitf61248278f3ee07b97dbce80b56c7cafc633ea82 (patch)
treed4c3b23583d656e53de20c99c8a8cfde6bd8bc23 /rst_context.lua
parentaaa9cbae61d38d9011270d1a6a19226fd5258be2 (diff)
downloadcontext-rst-f61248278f3ee07b97dbce80b56c7cafc633ea82.tar.gz
so called “citation references” (stub); inline markup in footnotes.
Diffstat (limited to 'rst_context.lua')
-rw-r--r--rst_context.lua28
1 files changed, 23 insertions, 5 deletions
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