summaryrefslogtreecommitdiff
path: root/rst_parser.lua
diff options
context:
space:
mode:
Diffstat (limited to 'rst_parser.lua')
-rw-r--r--rst_parser.lua53
1 files changed, 40 insertions, 13 deletions
diff --git a/rst_parser.lua b/rst_parser.lua
index 432f11a..46142ba 100644
--- a/rst_parser.lua
+++ b/rst_parser.lua
@@ -55,9 +55,10 @@ state.bullets.max = 0
state.lastbullet = ""
state.lastbullets = {}
state.roman_cache = {} -- storing roman numerals that were already converted
-state.currentindent = "" -- used in definition lists and elsewhere
-state.currentwidth = 0 -- table layout
-state.currentlayout = {} -- table layout
+state.currentindent = "" -- used in definition lists and elsewhere
+state.previousindent = "" -- for literal blocks included in paragraphs to restore the paragraph indent
+state.currentwidth = 0 -- table layout
+state.currentlayout = {} -- table layout
state.footnotes = {}
state.footnotes.autonumber = 0
@@ -987,14 +988,26 @@ local parser = P{
-- Paragraphs * Inline Markup
--------------------------------------------------------------------------------
- paragraph = V"par_setindent"
- * Ct(C((1 - V"eol")^1) * V"eol"
- * (V"par_matchindent" * C((1 - V"eol")^1) * V"eol")^0)
+ --paragraph = V"par_setindent"
+ --* Ct(C((1 - V"eol")^1) * V"eol"
+ --* (V"par_matchindent" * C((1 - V"eol")^1) * V"eol")^0)
+ --* V"end_block"
+ --/ rst.paragraph,
+
+ paragraph = Ct(V"par_first"
+ * V"par_other"^0)
* V"end_block"
/ rst.paragraph,
+ par_first = V"par_setindent" * C((1 - V"eol")^1) * V"eol",
+
+ par_other = V"par_matchindent"
+ * C((1 - V"literal_block_shorthand" - V"eol")^1)
+ * (V"included_literal_block" + V"eol"),
+
par_setindent = Cmt(V"space"^0, function (s, i, indent)
warn("par-i", #indent, "", "", i)
+ state.previousindent = state.currentindent
state.currentindent = indent
return true
end),
@@ -1013,17 +1026,31 @@ 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" / "")
+ * V"literal_block_markerless"
+ * Cmt(Cp(), function (s, i, _)
+ warn("par-s", "", #state.previousindent, #state.currentindent, i)
+ state.currentindent = state.previousindent
+ return true
+ end)
+ ,
+
+ --literal_block_shorthand = ((V"colon" * V"space"^1)^-1
+ --* V"double_colon") / ":"
+ --* (V"eol" * V"blank_line" / "")
+ --,
+
+ literal_block_shorthand = (((V"double_colon" * V"space"^0)
+ + (V"colon" * V"space"^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,
+ --* V"end_block"
+ * V"blank_line"
+ / rst.included_literal_block
+ ,
--------------------------------------------------------------------------------
-- Comments