summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-04 15:12:11 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-04 15:12:11 +0200
commit97647fd120edfe0c226ac8b51f12e19a1a325535 (patch)
tree38a62d8e4770f21b4a46ff5b593ed8b9a14ec941
parent8de852e3bb1c965fe3caf4be344067fcee737899 (diff)
downloadcontext-rst-97647fd120edfe0c226ac8b51f12e19a1a325535.tar.gz
literal blocks inside paragraphs
-rw-r--r--rst_context.lua2
-rw-r--r--rst_parser.lua19
2 files changed, 18 insertions, 3 deletions
diff --git a/rst_context.lua b/rst_context.lua
index 3bcbbc5..f595a27 100644
--- a/rst_context.lua
+++ b/rst_context.lua
@@ -393,7 +393,7 @@ end
function rst_context.literal_block (str)
local indent = P" "^1
- local stripme = indent:match(str) - 1
+ local stripme = indent:match(str)
local strip = P{
[1] = "strip",
diff --git a/rst_parser.lua b/rst_parser.lua
index 470b789..c489849 100644
--- a/rst_parser.lua
+++ b/rst_parser.lua
@@ -582,9 +582,11 @@ local parser = P{
--------------------------------------------------------------------------------
paragraph = -(V"double_dot" + V"double_underscore") -- + V"bullet_indent")
- * Cs((V"enclosed_inline"
+ * Cs((V"included_literal_block"
+ + V"enclosed_inline"
+ V"inline_elements"
+ V"word"
+ + V"punctuation"
+ (V"eol" - V"endpar")
+ V"spacing")^1)
* V"endpar"
@@ -663,6 +665,19 @@ local parser = P{
_reference = (1 - V"underscore" - V"spacing" - V"eol" - V"punctuation" - V"groupchars")^1 * V"underscore",
+ included_literal_block = V"literal_block_shorthand"
+ * V"literal_block_markerless",
+
+ literal_block_shorthand = ((V"colon" * V"space"^1)^-1
+ * V"double_colon") / ":"
+ * (V"eol" * V"blank_line" / "")
+ ,
+
+ literal_block_markerless = Cs(V"literal_block_lines"
+ * (V"blank_line"^1 * V"literal_block_lines")^0)
+ * V"blank_line"^0
+ / rst.literal_block,
+
--------------------------------------------------------------------------------
-- Comments
--------------------------------------------------------------------------------
@@ -721,7 +736,7 @@ local parser = P{
-- Terminal Symbols and Low-Level Elements
--------------------------------------------------------------------------------
- word = (1 - V"endpar" - V"spacing" - V"eol")^1, -- TODO : no punctuation (later)
+ word = (1 - V"punctuation" - V"endpar" - V"spacing" - V"eol")^1, -- TODO : no punctuation (later)
asterisk = P"*",
double_asterisk = V"asterisk" * V"asterisk",