From 9f89207cca864754aaad2edd2e50b3b0bf69fd07 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Sun, 2 Mar 2014 16:58:34 +0100 Subject: fix handling of locals inside itemization scanner --- src/rst_context.lua | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/rst_context.lua') diff --git a/src/rst_context.lua b/src/rst_context.lua index 1654832..db05537 100644 --- a/src/rst_context.lua +++ b/src/rst_context.lua @@ -817,10 +817,11 @@ function rst_context.startitemize(str) return result end -local last_item = {} -- stack +local item_stack = { } + local current_itemdepth = 0 function rst_context.stopitemize(str) - last_item[current_itemdepth] = nil + item_stack[current_itemdepth] = nil current_itemdepth = current_itemdepth - 1 return str .. [[ \\stopitemize @@ -828,7 +829,6 @@ function rst_context.stopitemize(str) end function rst_context.bullet_item (tab) - local li = last_item -- The capture of the first item has the \startitemize as -- *second* element in the array. local content = #tab == 2 and tab[2] or tab[3] @@ -837,17 +837,17 @@ function rst_context.bullet_item (tab) local result = startstr or "" if startstr then current_itemdepth = current_itemdepth + 1 - li[current_itemdepth] = itemtype - elseif li[current_itemdepth] then - if helpers.list.successor(itemtype, li[current_itemdepth]) then + item_stack[current_itemdepth] = itemtype + elseif item_stack[current_itemdepth] then + if helpers.list.successor(itemtype, item_stack[current_itemdepth]) then -- just leave it alone - elseif helpers.list.greater(itemtype, li[current_itemdepth]) then + elseif helpers.list.greater(itemtype, item_stack[current_itemdepth]) then local itemnum = tonumber(stringstrip(itemtype)) or helpers.list.get_decimal(itemtype) result = result .. stringformat([[ \\setnumber[itemgroup:itemize]{%s} ]], itemnum) end - li[current_itemdepth] = itemtype + item_stack[current_itemdepth] = itemtype end return result .. [[ -- cgit v1.2.3