diff options
author | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-09-13 20:22:37 +0200 |
---|---|---|
committer | Philipp Gesang <pgesang@ix.urz.uni-heidelberg.de> | 2010-09-13 20:22:37 +0200 |
commit | ecea85f8ec55ed7a6c25967d3ad620c8473bfd04 (patch) | |
tree | 6b0d5b4fc1e8aef9c16fb704e27774c482a2e590 | |
parent | f61248278f3ee07b97dbce80b56c7cafc633ea82 (diff) | |
download | context-rst-ecea85f8ec55ed7a6c25967d3ad620c8473bfd04.tar.gz |
fixed nasty bug in enumerations
-rw-r--r-- | rst_context.lua | 5 | ||||
-rw-r--r-- | rst_parser.lua | 39 |
2 files changed, 20 insertions, 24 deletions
diff --git a/rst_context.lua b/rst_context.lua index 575d756..e89934d 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -182,7 +182,8 @@ function rst_context.target (tab) end function rst_context.escape (str) - return str:gsub("\\(.)", "%1") + str = str:gsub("\\(.)", "%1") + return str end function rst_context.joinindented (tab) @@ -464,7 +465,7 @@ local stripme = S"()." local dontstrip = 1 - stripme local itemstripper = stripme^0 * C(dontstrip^1) * stripme^0 local function parse_itemstring(str) - local setup = [[\setupitemize[]] + local setup = [[\\setupitemize[]] -- string.match is slightly faster than string.find if str:match("^%(") then setup = setup .. [[left=(,]] diff --git a/rst_parser.lua b/rst_parser.lua index 3d0bdd5..d8ddb32 100644 --- a/rst_parser.lua +++ b/rst_parser.lua @@ -200,13 +200,14 @@ end local parser = P{ [1] = V"document", - document = Cs(V"block"^1), + document = V"blank_line"^0 * Cs(V"block"^1), -------------------------------------------------------------------------------- -- Blocks -------------------------------------------------------------------------------- block = V"target_block" + + Cs(V"list") / rst.escape + V"comment" + V"line_block" + Cs(V"table_block") / rst.escape @@ -215,7 +216,6 @@ local parser = P{ + V"literal_block" + Cs(V"block_quote") / rst.escape + V"explicit_markup" - + Cs(V"list") / rst.escape + Cs(V"paragraph") / rst.escape , @@ -231,7 +231,6 @@ local parser = P{ explicit_markup_start = V"double_dot" * V"whitespace", explicit_markup = V"footnote_block" - --+ V"citation" -- = \footcite --+ V"hyperlink_target" --+ V"directive" --+ V"substitution_definition" @@ -322,7 +321,6 @@ local parser = P{ simple_table = Ct(V"st_first_row" * V"st_other_rows") - --* V"blank_line"^1 * V"end_block" / function (tab) return rst.simple_table(helpers.table.simple(tab)) @@ -521,7 +519,7 @@ local parser = P{ * (V"blank_line" * V"block_quote_other"^1)^0) * (V"blank_line" * Cs(V"block_quote_attri"))^-1) - * V"blank_line" + * V"end_block" / rst.block_quote , @@ -549,7 +547,7 @@ local parser = P{ * V"block_quote_attri_other"^0, block_quote_attri_first = Cmt(V"space"^1 * V"attrib_dash" * V"space", function (s, i, indent) - local t = tracklists + local t = state warn("bqa-i", utf.len(indent), #t.currentindent, indent, t.currentindent, i) local ret = indent:match(" *") == t.currentindent @@ -699,8 +697,8 @@ local parser = P{ -------------------------------------------------------------------------------- list = V"option_list" - + V"definition_list" + V"bullet_list" + + V"definition_list" + V"field_list" , @@ -846,24 +844,24 @@ local parser = P{ bullet_list = V"bullet_init" --* (V"bullet_list" --+ V"bullet_continue")^0 - * (V"bullet_continue" - + V"bullet_list")^0 + --* (V"bullet_continue" + V"bullet_list")^0 + * (V"blank_line"^-1 * (V"bullet_list" + V"bullet_continue"))^0 * V"bullet_stop" * Cmt(Cc(nil), function (s, i) - local t = tracklists + local t = state warn("close", t.depth) t.bullets[t.depth] = nil -- “pop” t.depth = t.depth - 1 return true end), - --bullet_stop =V"blank_line" * Cs(Cc("")) / rst.stopitemize, - bullet_stop =V"end_block" * Cs(Cc("")) / rst.stopitemize, + --bullet_stop = V"blank_line" * Cs(Cc("")) / rst.stopitemize, + bullet_stop = V"end_block" * Cs(Cc("")) / rst.stopitemize, - bullet_init = V"eol"^0 * V"bullet_first" * V"bullet_itemrest", + bullet_init = V"bullet_first" * V"bullet_itemrest", bullet_first = #Cmt(V"bullet_indent", function (s, i, bullet) - local t = tracklists + local t = state local oldbullet = t.bullets[t.depth] local n_spaces = match(P" "^0, bullet) warn("first", @@ -894,7 +892,7 @@ local parser = P{ bullet_indent = V"space"^0 * V"bullet_expr" * V"space"^1, bullet_cont = Cmt(V"bullet_indent", function (s, i, bullet) - local t = tracklists + local t = state warn("conti", t.depth, bullet == t.bullets[t.depth], @@ -911,14 +909,12 @@ local parser = P{ elseif t.conversion(t.lastbullet) == t.conversion(bullet) then -- same type return t.conversion(bullet) == "auto" or t.successor(bullet, t.lastbullet) end - --return false return t.bullets[t.depth] == bullet end) / "", -- ^^^^^ -- otherwise returns the value of V"bullet_indent", not sure why … - bullet_continue = V"blank_line" - * V"bullet_cont" + bullet_continue = V"bullet_cont" * V"bullet_itemrest", bullet_itemrest = Cs(V"bullet_rest" -- first line @@ -933,8 +929,9 @@ local parser = P{ bullet_rest = Cs((1 - V"eol")^1 * V"eol"), -- rest of one line bullet_next = V"space"^1, + bullet_match = #Cmt(V"bullet_next", function (s, i, this) - local t = tracklists + local t = state warn("match", t.depth, string.len(this) == utf.len(t.bullets[t.depth]), @@ -975,8 +972,7 @@ local parser = P{ -- The whitespace handling after the overline is necessary because headings -- without overline aren't allowed to be indented. - section = V"blank_line"^0 - * (V"section_adorn" * V"whitespace"^0)^-1 + section = (V"section_adorn" * V"whitespace"^0)^-1 * C((1 - V"whitespace") * (1 - V"eol")^1) * V"eol" * V"section_adorn" @@ -1085,7 +1081,6 @@ local parser = P{ block_comment = V"eol" * Cs(V"indented_lines") * V"eol"^0 - --* V"blank_line"^0 / rst.block_comment, line_comment = Cs((1 - V"eol")^0 * V"eol") |