diff options
-rw-r--r-- | rst_context.lua | 8 | ||||
-rw-r--r-- | rst_parser.lua | 15 |
2 files changed, 16 insertions, 7 deletions
diff --git a/rst_context.lua b/rst_context.lua index e89934d..c3ec323 100644 --- a/rst_context.lua +++ b/rst_context.lua @@ -465,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 = ",fit][itemalign=flushright," -- string.match is slightly faster than string.find if str:match("^%(") then setup = setup .. [[left=(,]] @@ -476,7 +476,7 @@ local function parse_itemstring(str) if str:match("%.$") then setup = setup .. [[stopper=.]] end - setup = setup .. "]\n" + setup = setup str = itemstripper:match(str) return {setup = setup, str=str} @@ -494,8 +494,8 @@ function rst_context.startitemize(str) listtype = listtype.str end - return setup .. [[ -\\startitemize[]] .. listtype .. [[] + return [[ +\\startitemize[]] .. listtype .. setup .. [[] ]] end diff --git a/rst_parser.lua b/rst_parser.lua index d8ddb32..b3e5f27 100644 --- a/rst_parser.lua +++ b/rst_parser.lua @@ -53,6 +53,7 @@ state.depth = 0 state.bullets = {} -- mapping bullet forms to depth 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 @@ -852,6 +853,7 @@ local parser = P{ warn("close", t.depth) t.bullets[t.depth] = nil -- “pop” t.depth = t.depth - 1 + t.lastbullet = t.lastbullets[t.depth] return true end), @@ -867,7 +869,9 @@ local parser = P{ warn("first", t.depth, (t.depth == 0 and n_spaces == 1) or - (t.depth > 0 and n_spaces > 1), bullet, oldbullet, + (t.depth > 0 and n_spaces > 1), + bullet, + oldbullet, t.conversion(bullet)) if t.depth == 0 and n_spaces == 1 then -- first level @@ -878,6 +882,7 @@ local parser = P{ return true elseif t.depth > 0 and n_spaces > 1 then -- sublist (of sublist)^0 if n_spaces >= utf.len(oldbullet) then + t.lastbullets[t.depth] = t.lastbullet t.depth = t.depth + 1 t.bullets[t.depth] = bullet t.lastbullet = bullet @@ -898,6 +903,7 @@ local parser = P{ bullet == t.bullets[t.depth], bullet, t.bullets[t.depth], + t.lastbullets[t.depth], t.conversion(t.lastbullet), t.conversion(bullet) ) @@ -907,9 +913,12 @@ local parser = P{ elseif not t.conversion(bullet) and t.bullets[t.depth] == bullet then return true elseif t.conversion(t.lastbullet) == t.conversion(bullet) then -- same type - return t.conversion(bullet) == "auto" or t.successor(bullet, t.lastbullet) + local autoconv = t.conversion(bullet) == "auto" + local successor = t.successor(bullet, t.lastbullet) + t.lastbullet = bullet + return autoconv or successor end - return t.bullets[t.depth] == bullet + --return t.bullets[t.depth] == bullet end) / "", -- ^^^^^ -- otherwise returns the value of V"bullet_indent", not sure why … |