summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-04 11:12:29 +0200
committerPhilipp Gesang <pgesang@ix.urz.uni-heidelberg.de>2010-09-04 11:12:29 +0200
commit5a9490c529fd711555f6dda702593602fc08d404 (patch)
treec1841d5e93c3b2c7b66455aef837ec255f1a91e8
parent1cc2bd29d90b5f8e60e3e51976666999dfbeabfa (diff)
downloadcontext-rst-5a9490c529fd711555f6dda702593602fc08d404.tar.gz
commented blocks
-rw-r--r--rst_context.lua17
-rw-r--r--rst_parser.lua67
2 files changed, 57 insertions, 27 deletions
diff --git a/rst_context.lua b/rst_context.lua
index 7d0ef28..ff3851d 100644
--- a/rst_context.lua
+++ b/rst_context.lua
@@ -323,6 +323,10 @@ end
-- Field lists
--------------------------------------------------------------------------------
+-- TODO Do something useful with field lists. For now I'm not sure what as the
+-- bibliography directives from the reST specification seem to make sense only
+-- when using docinfo and, after all, we have .bib files that are portable.
+
function rst_context.field_list (str)
return [[
@@ -349,4 +353,17 @@ function rst_context.field (tab)
]], name, body)
end
+function rst_context.line_comment (str)
+ return "% " .. str
+end
+
+function rst_context.block_comment (str)
+ return string.format([[
+
+\iffalse
+%s
+\fi
+]], str)
+end
+
return rst_context
diff --git a/rst_parser.lua b/rst_parser.lua
index 5b6a1e9..6466b81 100644
--- a/rst_parser.lua
+++ b/rst_parser.lua
@@ -193,11 +193,12 @@ local parser = P{
--------------------------------------------------------------------------------
block = V"target_block"
+ + V"comment"
+ Cs(V"section") / rst.escape
+ Cs(V"transition") --/ rst.escape
+ Cs(V"list") / rst.escape
+ Cs(V"paragraph") / rst.escape
- + V"comment",
+ ,
--------------------------------------------------------------------------------
-- Lists
@@ -232,29 +233,6 @@ local parser = P{
field_body = C(V"rest_of_line" * V"eol"
* V"indented_lines"^-1),
- indented_lines = V"indented_first"
- * (V"indented_other"
- - V"field_marker")^0,
-
- indented_first = Cmt(V"space"^1, function (s, i, indent)
- warn("idt-f", indent, i)
- if not indent or
- indent == "" then
- return false
- end
- tracklists.currentindent = indent
- return true
- end)
- * V"rest_of_line"
- * V"eol",
-
- indented_other = Cmt(V"space"^1, function (s, i, indent)
- warn("idt-m", indent, tracklists.currentindent, indent == tracklists.currentindent, i)
- return indent == tracklists.currentindent
- end)
- * V"rest_of_line"
- * V"eol",
-
--------------------------------------------------------------------------------
-- Definition lists
--------------------------------------------------------------------------------
@@ -600,9 +578,44 @@ local parser = P{
-- Comments
--------------------------------------------------------------------------------
- comment = Cs(V"doubledot"
- * (1 - V"eol")^0
- * V"eol") / ">>comment<<",
+ comment = V"block_comment" + V"line_comment",
+
+ block_comment = V"doubledot" * V"whitespace"^0 * V"eol"
+ * Cs(V"indented_lines")
+ * V"eol"^0
+ --* V"blank_line"^0
+ / rst.block_comment,
+
+ line_comment = V"doubledot" * V"whitespace"^0
+ * Cs((1 - V"eol")^0 * V"eol")
+ / rst.line_comment,
+
+--------------------------------------------------------------------------------
+-- Generic indented block
+--------------------------------------------------------------------------------
+
+ indented_lines = V"indented_first"
+ * (V"indented_other"
+ - V"blank_line" - V"field_marker")^0,
+
+ indented_first = Cmt(V"space"^1, function (s, i, indent)
+ warn("idt-f", indent, i)
+ if not indent or
+ indent == "" then
+ return false
+ end
+ tracklists.currentindent = indent
+ return true
+ end)
+ * V"rest_of_line"
+ * V"eol",
+
+ indented_other = Cmt(V"space"^1, function (s, i, indent)
+ warn("idt-m", indent, tracklists.currentindent, indent == tracklists.currentindent, i)
+ return indent == tracklists.currentindent
+ end)
+ * V"rest_of_line"
+ * V"eol",
--------------------------------------------------------------------------------
-- Urls