summaryrefslogtreecommitdiff
path: root/rst_context.lua
diff options
context:
space:
mode:
Diffstat (limited to 'rst_context.lua')
-rw-r--r--rst_context.lua59
1 files changed, 55 insertions, 4 deletions
diff --git a/rst_context.lua b/rst_context.lua
index 96e7f89..bc96a9a 100644
--- a/rst_context.lua
+++ b/rst_context.lua
@@ -48,6 +48,23 @@ rst_context.last_section_level = 0
rst_context.anonymous_links = 0
rst_context.context_references = {}
+rst_context.current_footnote_number = 0
+
+function rst_context.footnote_reference (label)
+ local tf = tracklists.footnotes
+ if label:match("^%d+$") then -- all digits
+ -- TODO
+ elseif label == "#" then --autonumber
+ rst_context.current_footnote_number = rst_context.current_footnote_number + 1
+ print("creating footnote nr " .. rst_context.current_footnote_number)
+ return [[\\footnote{\\getbuffer[__autonumber]]..rst_context.current_footnote_number.."]}"
+ elseif label:match("^#.+$") then
+ -- TODO
+ elseif label == "*" then
+ -- TODO
+ end
+end
+
-- So we can use crefs[n][2] to refer to the place where the reference was
-- created.
local function get_context_reference (str)
@@ -153,14 +170,13 @@ local inline_parser = P{
block = Cs((V"inline_element" + 1)^1),
- inline_element = Cs(V"precede_inline"
- * (V"strong_emphasis"
+ inline_element = Cs((V"strong_emphasis"
+ V"emphasis"
+ V"inline_literal"
+ V"interpreted_text"
-- + V"inline_internal_target" -- TODO
+ V"reference"
--- + V"footnote_reference" -- TODO
+ + V"footnote_reference" -- TODO
-- + V"substitution_reference" -- TODO
+ V"link_standalone")
* V"succede_inline"),
@@ -196,7 +212,6 @@ local inline_parser = P{
triple_dash = V"double_dash" * V"dash",
hyphen = P"‐",
dashes = V"dash" + P"‒" + P"–" + V"emdash" + P"―",
- letter = R"az" + R"AZ",
groupchars = S"()[]{}",
apostrophe = P"’" + P"'",
@@ -205,6 +220,13 @@ local inline_parser = P{
solidus= P"⁄",
slash = P"/",
+ gartenzaun = P"#",
+ lsquare = P"[",
+ rsquare = P"]",
+
+ digit = R"09",
+ letter = R"az" + R"AZ",
+
punctuation = V"apostrophe"
+ V"colon"
+ V"comma"
@@ -277,6 +299,16 @@ 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"
+ / rst_context.footnote_reference
+ ,
+
+ footnote_label = V"digit"^1
+ + V"gartenzaun"
+ + V"gartenzaun" * V"letter"^1
+ + V"asterisk"
+ ,
+
--------------------------------------------------------------------------------
-- Urls
--------------------------------------------------------------------------------
@@ -807,4 +839,23 @@ function rst_context.simple_table(tab)
return head .. body .. tail
end
+function rst_context.footnote(label, content)
+ local tf = tracklists.footnotes
+ if label:match("^%d+$") then -- all digits
+ tf.numbered[tonumber(label)] = 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
+ elseif label:match("^#.+$") then
+ local thelabel = label:match("^#(.+)$")
+ tf.autolabel[thelabel] = content
+ elseif label == "*" then
+ tf.symbol[#tf.symbol+1] = content
+ end
+ return ""
+end
+
+
return rst_context