summaryrefslogtreecommitdiff
path: root/rst_parser.lua
diff options
context:
space:
mode:
Diffstat (limited to 'rst_parser.lua')
-rw-r--r--rst_parser.lua112
1 files changed, 25 insertions, 87 deletions
diff --git a/rst_parser.lua b/rst_parser.lua
index 768f689..d68645f 100644
--- a/rst_parser.lua
+++ b/rst_parser.lua
@@ -225,7 +225,6 @@ local parser = P{
grid_table = Ct(V"gt_first_row"
* V"gt_other_rows")
* V"blank_line"^1
- --/ rst.grid_table
/ function(tab)
return rst.grid_table(helpers.table.create(tab))
end
@@ -330,7 +329,7 @@ local parser = P{
return true
end) / ""
* -V"attrib_dash"
- * V"text_element"^1
+ * (1 - V"eol")^1
* V"eol"
,
@@ -340,7 +339,7 @@ local parser = P{
return tracklists.currentindent == indent
end) / ""
* -V"attrib_dash"
- * V"text_element"^1
+ * (1 - V"eol")^1
* V"eol"
,
@@ -355,7 +354,7 @@ local parser = P{
t.currentindent = ret and indent or t.currentindent
return ret
end) / ""
- * V"text_element"^1
+ * (1 - V"eol")^1
* V"eol"
,
@@ -364,7 +363,7 @@ local parser = P{
indent, tracklists.currentindent, i)
return utf.len(tracklists.currentindent) == #indent
end) / ""
- * V"text_element"^1
+ * (1 - V"eol")^1
* V"eol"
,
@@ -407,7 +406,7 @@ local parser = P{
* V"line_block_line"
,
- line_block_line = Cs(V"text_element"^1
+ line_block_line = Cs((1 - V"eol")^1
* V"line_block_cont"^0
* V"eol")
/ rst.line_block_line
@@ -418,7 +417,7 @@ local parser = P{
warn("lbk-c", #spaces, #tracklists.currentindent, spaces, tracklists.currentindent, i)
return #spaces >= #tracklists.currentindent
end) / ""
- * V"text_element"^1
+ * (1 - V"eol")^1
,
--------------------------------------------------------------------------------
@@ -521,12 +520,12 @@ local parser = P{
option_desc_single = V"space"^2
--* V"rest_of_line"
- * V"text_element"^1
+ * (1 - V"eol")^1
* V"eol",
option_desc_more = V"space"^2
--* V"rest_of_line"
- * V"text_element"^1
+ * (1 - V"eol")^1
* V"eol"
* V"indented_lines"
* (V"blank_line" * V"indented_lines")^0,
@@ -575,7 +574,7 @@ local parser = P{
field_name = (V"escaped_colon" + (1 - V"colon"))^1,
- field_body = C(V"text_element"^1 * V"eol"
+ field_body = C((1 - V"eol")^1 * V"eol"
* V"indented_lines"^-1),
--------------------------------------------------------------------------------
@@ -837,84 +836,23 @@ local parser = P{
-- Paragraphs * Inline Markup
--------------------------------------------------------------------------------
- --paragraph = -(V"double_dot" + V"double_underscore") -- + V"bullet_indent")
- paragraph = -V"punctuation"
- * Cs((V"text_element" + (V"eol" - V"endpar"))^1)
- * V"endpar"
+ paragraph = V"par_setindent"
+ * Ct(C((1 - V"eol")^1) * V"eol"
+ * (V"par_matchindent" * C((1 - V"eol")^1) * V"eol")^0)
+ * V"blank_line"^1
+ --* V"endpar"
/ rst.paragraph,
- text_element = V"included_literal_block"
- + V"enclosed_inline"
- + V"inline_elements"
- + V"word"
- + V"punctuation"
- + V"spacing"
- ,
+ par_setindent = Cmt(V"space"^0, function (s, i, indent)
+ warn("par-i", #indent, "", "", i)
+ tracklists.currentindent = indent
+ return true
+ end),
- -- Ignore single occurences of inline markup delimiters in certain
- -- environments.
- enclosed_inline = Cg(V"enclosed_open", "opener")
- * V"inline_delimiter"
- * Cmt(C(V"enclosed_close") * Cb("opener"), function(i, p, closer, opener)
- return closer == enclosed_mapping[opener]
- end),
-
- precede_inline = V"spacing"
- + V"eol"
- + S[['"([{<-/:]]
- + P"‘" + P"“" + P"’" + P"«" + P"¡" + P"¿"
- + V"delimiters"
- + P"„", -- not in standard Murkin reST
-
- succede_inline = V"spacing"
- + S[['")]}>-/:.,;!?\]]
- + P"’" + P"”" + P"»"
- + V"delimiters"
- + P"“", -- non-standard again but who cares
-
- inline_elements = Cs(V"precede_inline"
- * (V"strong_emphasis"
- + V"emphasis"
- + V"inline_literal"
- + V"interpreted_text"
--- + V"inline_internal_target" -- TODO
- + V"reference"
--- + V"footnote_reference" -- TODO
--- + V"substitution_reference" -- TODO
- + V"link_standalone")
- * V"succede_inline"),
-
- emphasis = (V"asterisk" - V"double_asterisk")
- * Cs((1 - V"spacing" - V"eol" - V"asterisk")
- * ((1 - (1 * V"asterisk"))^0
- * (1 - V"spacing" - V"eol" - V"asterisk"))^-1) -- looks like lisp
- * V"asterisk"
- / rst.emphasis,
-
- strong_emphasis = V"double_asterisk"
- * Cs((1 - V"spacing" - V"eol" - V"asterisk")
- * ((1 - (1 * V"double_asterisk"))^0
- * (1 - V"spacing" - V"eol" - V"asterisk"))^-1)
- * V"double_asterisk"
- / rst.strong_emphasis,
-
- inline_literal = V"double_bareia"
- * C ((V"escaped_bareia" - V"spacing" - V"eol" - V"bareia")
- * ((V"escaped_bareia" - (1 * V"double_bareia"))^0
- * (V"escaped_bareia" - V"spacing" - V"eol" - V"bareia"))^-1)
- * V"double_bareia"
- / rst.literal,
-
- interpreted_text = C(V"role_marker"^-1)
- * (V"bareia" - V"double_bareia")
- * C ((1 - V"spacing" - V"eol" - V"bareia")
- * ((1 - (1 * V"bareia"))^0
- * (1 - V"spacing" - V"eol" - V"bareia"))^-1)
- * V"bareia"
- * C(V"role_marker"^-1)
- / rst.interpreted_text,
-
- role_marker = V"colon" * (V"letter" + V"dash" + V"underscore" + V"dot")^1 * V"colon",
+ par_matchindent = Cmt(V"space"^0, function (s, i, indent)
+ warn("par-m", tracklists.currentindent == indent, #indent, #tracklists.currentindent, i)
+ return tracklists.currentindent == indent
+ end),
link_standalone = C(V"uri")
/ rst.link_standalone,
@@ -970,14 +908,14 @@ local parser = P{
tracklists.currentindent = indent
return true
end)
- * V"text_element"^1
+ * (1 - V"eol")^1
* 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"text_element"^1
+ * (1 - V"eol")^1
* V"eol",
--------------------------------------------------------------------------------