summaryrefslogtreecommitdiff
path: root/rst_parser.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-15 18:06:33 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-15 18:06:33 +0200
commitf1786af10f0be9675f83a335581593d45d56836c (patch)
tree66b1b8808b8eed83c32574b07788f830b3ef031d /rst_parser.lua
parentbe4f91df9499f6a6db891afbc680438795ce0606 (diff)
downloadcontext-rst-f1786af10f0be9675f83a335581593d45d56836c.tar.gz
multi-line substitution definitions
Diffstat (limited to 'rst_parser.lua')
-rw-r--r--rst_parser.lua55
1 files changed, 41 insertions, 14 deletions
diff --git a/rst_parser.lua b/rst_parser.lua
index 1ef0aa0..88c894d 100644
--- a/rst_parser.lua
+++ b/rst_parser.lua
@@ -143,14 +143,40 @@ local parser = P{
* V"whitespace"
* C((1 - V"colon" - V"space" - V"eol")^1) -- directive
* V"double_colon"
- * C(V"data_directive_block")
- * V"blank_line"^-1
+ * Ct(V"data_directive_block")
+ --* V"blank_line"^-1
/ rst.substitution_definition
,
- data_directive_block = V"rest_of_line" * V"eol"
- * V"indented_lines"^-1 -- nothing said about definitions
- , -- spanning multiple paragraphs
+ data_directive_block = V"data_directive_block_long"
+ + V"data_directive_block_short"
+ ,
+ data_directive_block_short = C((1 - V"eol")^0) * V"eol",
+
+ data_directive_block_long = C((1 - V"eol")^0) * V"eol"
+ * V"directive_indented_lines"
+ ,
+
+ directive_indented_lines = V"directive_indented_first"
+ * V"directive_indented_other"^0
+ ,
+
+
+ directive_indented_first = Cmt(V"space"^1, function(s,i,indent)
+ warn("sub-i", #indent, i)
+ state.currentindent = indent
+ return true
+ end)
+ * C((1 - V"eol")^1) * V"eol"
+ ,
+
+ directive_indented_other = Cmt(V"space"^1, function(s,i,indent)
+ warn("sub-m", #state.currentindent <= #indent, #indent, #state.currentindent, i)
+ return #state.currentindent <= #indent
+ end)
+ * C((1 - V"eol")^1) * V"eol"
+ ,
+
--------------------------------------------------------------------------------
-- Explicit markup footnote block
@@ -611,10 +637,11 @@ local parser = P{
-- Lists
--------------------------------------------------------------------------------
- list = V"option_list"
- + V"bullet_list"
- + V"definition_list"
- + V"field_list"
+ list = (V"option_list"
+ + V"bullet_list"
+ + V"definition_list"
+ + V"field_list")
+ - V"explicit_markup_start"
,
--------------------------------------------------------------------------------
@@ -1024,10 +1051,10 @@ local parser = P{
indented_first = Cmt(V"space"^1, function (s, i, indent)
warn("idt-f", indent, i)
- if not indent or
- indent == "" then
- return false
- end
+ --if not indent or
+ --indent == "" then
+ --return false
+ --end
state.currentindent = indent
return true
end)
@@ -1035,7 +1062,7 @@ local parser = P{
* V"eol",
indented_other = Cmt(V"space"^1, function (s, i, indent)
- warn("idt-m", indent, state.currentindent, indent == state.currentindent, i)
+ warn("idt-m", #indent, #state.currentindent, #indent == #state.currentindent, i)
return indent == state.currentindent
end)
* (1 - V"eol")^1