summaryrefslogtreecommitdiff
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
parentaaa9cbae61d38d9011270d1a6a19226fd5258be2 (diff)
downloadcontext-rst-f61248278f3ee07b97dbce80b56c7cafc633ea82.tar.gz
so called “citation references” (stub); inline markup in footnotes.
-rw-r--r--rst_context.lua28
-rw-r--r--rst_parser.lua13
2 files changed, 27 insertions, 14 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
diff --git a/rst_parser.lua b/rst_parser.lua
index d4ad90b..3d0bdd5 100644
--- a/rst_parser.lua
+++ b/rst_parser.lua
@@ -245,25 +245,23 @@ local parser = P{
footnote_block = V"footnote"^1 * V"end_block",
footnote = V"explicit_markup_start"
- * V"footnote_marker"
+ * (V"footnote_marker" + V"citation_reference_label")
* C(V"footnote_content")
* (V"blank_line" - V"end_block")^-1
- --* C(V"block")
/ rst.footnote
,
footnote_marker = V"lsquare" * C(V"footnote_label") * V"rsquare" * V"whitespace"^0
,
+ citation_reference_label = V"lsquare" * C(V"letter" * (1 - V"rsquare")^1) * V"rsquare" * V"whitespace"^0,
+
footnote_label = V"digit"^1
+ (V"gartenzaun" * V"letter"^1)
+ V"gartenzaun"
+ V"asterisk"
,
- --footnote_content = V"footnote_simple" -- single line
- --+ V"footnote_long"
-
footnote_content = V"footnote_long" -- single line
+ V"footnote_simple"
,
@@ -275,10 +273,6 @@ local parser = P{
* V"footnote_body"
,
- --footnote_body = V"fn_body_first"
- --* (V"fn_body_other" * (V"blank_line" * V"fn_body_other")^0)^0
- --,
-
footnote_body = V"fn_body_first"
* (V"fn_body_other" + V"fn_body_other_block")^0
,
@@ -1288,6 +1282,7 @@ local function get_setups ()
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setupcolors[state=start]
\setupinteraction[state=start,color=darkgreen,contrastcolor=darkgreen]
+\setupbodyfontenvironment [default] [em=italic]
]]
for item, _ in next, state.addme do