summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-04 16:00:08 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-04 16:00:08 +0200
commitbd98935ced1b94ff40cfa8335fdaabf92645676b (patch)
tree9732d07095104c07c4cf320a3a7233ad2e4a1329
parente58224b3f63188bfb6919e320d193a29fcd586fb (diff)
downloadcontext-rst-bd98935ced1b94ff40cfa8335fdaabf92645676b.tar.gz
quoted literal blocks
-rw-r--r--rst_context.lua2
-rw-r--r--rst_parser.lua51
2 files changed, 45 insertions, 8 deletions
diff --git a/rst_context.lua b/rst_context.lua
index f595a27..ee943ab 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)
+ local stripme = indent:match(str) or 0
local strip = P{
[1] = "strip",
diff --git a/rst_parser.lua b/rst_parser.lua
index 99265bd..2aa4e38 100644
--- a/rst_parser.lua
+++ b/rst_parser.lua
@@ -205,17 +205,31 @@ local parser = P{
-- Literal blocks
--------------------------------------------------------------------------------
+ literal_block = V"unquoted_literal_block"
+ + V"quoted_literal_block",
+
+--------------------------------------------------------------------------------
+-- Quoted literal blocks
+--------------------------------------------------------------------------------
+
literal_block = V"literal_block_marker"
- * Cs(V"literal_block_lines"
- * (V"blank_line"^1 * V"literal_block_lines")^0)
- * V"blank_line"^0
- / rst.literal_block,
+ * Cs(V"literal_block_lines"
+ * (V"blank_line"^1 * V"literal_block_lines")^0)
+ * V"blank_line"^0
+ / rst.literal_block,
literal_block_marker = V"double_colon" * V"eol" * V"blank_line",
- literal_block_lines = V"literal_block_first"
- * (V"literal_block_other"
- - V"blank_line")^0,
+ literal_block_lines = V"unquoted_literal_block_lines"
+ + V"quoted_literal_block_lines",
+
+ unquoted_literal_block_lines = V"literal_block_first"
+ * (V"literal_block_other"
+ - V"blank_line")^0,
+
+ quoted_literal_block_lines = V"quoted_literal_block_first"
+ * (V"quoted_literal_block_other"
+ - V"blank_line")^0,
literal_block_first = Cmt(V"space"^1, function (s, i, indent)
warn("lbk-f", #indent, "", "", i)
@@ -240,6 +254,29 @@ local parser = P{
* V"rest_of_line"
* V"eol",
+ quoted_literal_block_first = Cmt(V"adornment_char", function (s, i, indent)
+ warn("lbk-f", #indent, "", "", i)
+ if not indent or
+ indent == "" then
+ return false
+ end
+ tracklists.currentindent = indent
+ return true
+ end)
+ * V"rest_of_line"
+ * V"eol",
+
+ quoted_literal_block_other = Cmt(V"adornment_char", function (s, i, indent)
+ warn("lbk-m",
+ #indent,
+ #tracklists.currentindent,
+ #indent >= #tracklists.currentindent,
+ i)
+ return #indent >= #tracklists.currentindent
+ end)
+ * V"rest_of_line"
+ * V"eol",
+
--------------------------------------------------------------------------------
-- Lists
--------------------------------------------------------------------------------