diff options
Diffstat (limited to 'src/rst_parser.lua')
-rw-r--r-- | src/rst_parser.lua | 78 |
1 files changed, 42 insertions, 36 deletions
diff --git a/src/rst_parser.lua b/src/rst_parser.lua index 10994d9..82e906a 100644 --- a/src/rst_parser.lua +++ b/src/rst_parser.lua @@ -900,11 +900,12 @@ local rst_parser = P { * (V"blank_line"^-1 * (V"bullet_list" + V"bullet_continue"))^1 * V"bullet_stop" * Cmt(Cc(nil), function (s, i) - local t = state - warn("close", t.depth) - t.bullets[t.depth] = nil -- “pop” - t.depth = t.depth - 1 - t.lastbullet = t.lastbullets[t.depth] + local depth = state.depth + warn("close", depth) + state.bullets[depth] = nil -- “pop” + depth = depth - 1 + state.lastbullet = state.lastbullets[depth] + state.depth = depth return true end), @@ -915,30 +916,32 @@ local rst_parser = P { , bullet_first = #Cmt(V"bullet_indent", function (s, i, bullet) - local t = state - local oldbullet = t.bullets[t.depth] - local n_spaces = lpegmatch(P" "^0, bullet) + local depth = state.depth + local bullets = state.bullets + local oldbullet = state.bullets[depth] + local n_spaces = lpegmatch(P" "^0, bullet) warn("first", - t.depth, - (t.depth == 0 and n_spaces >= 1) or - (t.depth > 0 and n_spaces > 1), + depth, + (depth == 0 and n_spaces >= 1) or (depth > 0 and n_spaces > 1), bullet, oldbullet, helpers.list.conversion(bullet)) - if t.depth == 0 and n_spaces >= 1 then -- first level - t.depth = 1 -- “push” - t.bullets[1] = bullet - t.lastbullet = bullet - t.bullets.max = t.bullets.max < t.depth and t.depth or t.bullets.max + if depth == 0 and n_spaces >= 1 then -- first level + depth = 1 -- “push” + bullets[1] = bullet + state.lastbullet = bullet + bullets.max = bullets.max < depth and depth or bullets.max + state.depth = depth return true - elseif t.depth > 0 and n_spaces > 1 then -- sublist (of sublist)^0 + elseif depth > 0 and n_spaces > 1 then -- sublist (of sublist)^0 if n_spaces >= utflen(oldbullet) then - t.lastbullets[t.depth] = t.lastbullet - t.depth = t.depth + 1 - t.bullets[t.depth] = bullet - t.lastbullet = bullet - t.bullets.max = t.bullets.max < t.depth and t.depth or t.bullets.max + state.lastbullets[depth] = state.lastbullet + depth = depth + 1 + bullets[depth] = bullet + state.lastbullet = bullet + bullets.max = bullets.max < depth and depth or bullets.max + state.depth = depth return true end end @@ -951,29 +954,32 @@ local rst_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 = state - local conversion = helpers.list.conversion + local conversion = helpers.list.conversion + local depth = state.depth + local bullets = state.bullets + local lastbullets = state.lastbullets warn("conti", - t.depth, - bullet == t.bullets[t.depth], + depth, + bullet == bullets[depth], bullet, - t.bullets[t.depth], - t.lastbullets[t.depth], - conversion(t.lastbullet), + bullets[depth], + lastbullets[depth], + conversion(state.lastbullet), conversion(bullet) ) - if utflen(t.bullets[t.depth]) ~= utflen(bullet) then + if utflen(bullets[depth]) ~= utflen(bullet) then return false - elseif not conversion(bullet) and t.bullets[t.depth] == bullet then + elseif not conversion(bullet) and bullets[depth] == bullet then return true - elseif conversion(t.lastbullet) == conversion(bullet) then -- same type + elseif conversion(state.lastbullet) == conversion(bullet) then -- same type local autoconv = conversion(bullet) == "auto" - local greater = helpers.list.greater (bullet, t.lastbullet) - t.lastbullet = bullet + local greater = helpers.list.greater (bullet, state.lastbullet) + state.lastbullet = bullet return autoconv or successor or greater end - end), + end) + , bullet_continue = Ct(C(V"bullet_cont") * V"bullet_itemrest") /rst.bullet_item @@ -1549,7 +1555,7 @@ local get_tmpfile = function (category) cnt = cnt + 1 tempfile_count[category] = cnt return luatex.registertempfile ( - stringformat ("%s_rst-%s-%d", + stringformat ("%s_rst-%s-%d.tmp", tex.jobname, category, cnt) |