summaryrefslogtreecommitdiff
path: root/rst_parser.lua
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-04 14:13:11 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-04 14:13:11 +0200
commitd64ebfaca1adf349d7d0bd29c2dde84422ba3025 (patch)
treebf51f9c54730fbd92386429447b3b94959d2c925 /rst_parser.lua
parent97aa5f28b096e2439d87a617c17eae52171e80d6 (diff)
downloadcontext-rst-d64ebfaca1adf349d7d0bd29c2dde84422ba3025.tar.gz
literal blocks
Diffstat (limited to 'rst_parser.lua')
-rw-r--r--rst_parser.lua49
1 files changed, 47 insertions, 2 deletions
diff --git a/rst_parser.lua b/rst_parser.lua
index 7b739bd..470b789 100644
--- a/rst_parser.lua
+++ b/rst_parser.lua
@@ -196,11 +196,51 @@ local parser = P{
+ V"comment"
+ Cs(V"section") / rst.escape
+ Cs(V"transition") --/ rst.escape
+ + V"literal_block"
+ Cs(V"list") / rst.escape
+ Cs(V"paragraph") / rst.escape
,
--------------------------------------------------------------------------------
+-- 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,
+
+ 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_first = Cmt(V"space"^1, 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",
+
+ literal_block_other = Cmt(V"space"^1, 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
--------------------------------------------------------------------------------
@@ -247,7 +287,9 @@ local parser = P{
+ V"option_dos_vms")
* V"option_arg"^-1,
- option_arg = (V"equals" + V"space") * V"letter"^1,
+ option_arg = (V"equals" + V"space")
+ * ((V"letter" * (V"letter" + V"digit")^1)
+ + (V"angle_left" * (1 - V"angle_right")^1 * V"angle_right")),
option_posixshort = V"dash" * (V"letter" + V"digit"),
@@ -697,6 +739,7 @@ local parser = P{
comma = P",",
colon = P":",
+ double_colon = V"colon" * V"colon",
escaped_colon = V"backslash" * V"colon",
dot = P".",
double_dot = V"dot" * V"dot",
@@ -737,11 +780,13 @@ local parser = P{
Roman_numeral = S"IVXLCDM"^1,
inline_delimiter = P"**" + P"``" + S"*`",
+ angle_left = P"<",
+ angle_right = P">",
enclosed_open = S[['"([{<]],
enclosed_close = S[['")]}>]],
}
-f = io.open("option_lists.rst", "r")
+f = io.open("litblock.rst", "r")
testdata = f:read("*all")
f:close()