diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rst_context.lua | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/rst_context.lua b/src/rst_context.lua index db05537..699064e 100644 --- a/src/rst_context.lua +++ b/src/rst_context.lua @@ -819,10 +819,8 @@ end local item_stack = { } -local current_itemdepth = 0 function rst_context.stopitemize(str) - item_stack[current_itemdepth] = nil - current_itemdepth = current_itemdepth - 1 + item_stack[#item_stack] = nil return str .. [[ \\stopitemize ]] @@ -836,18 +834,18 @@ function rst_context.bullet_item (tab) local itemtype = tab[1] local result = startstr or "" if startstr then - current_itemdepth = current_itemdepth + 1 - item_stack[current_itemdepth] = itemtype - elseif item_stack[current_itemdepth] then - if helpers.list.successor(itemtype, item_stack[current_itemdepth]) then + item_stack[#item_stack + 1] = itemtype + elseif next (item_stack) then + local current_item = item_stack [#item_stack] + if helpers.list.successor(itemtype, current_item) then -- just leave it alone - elseif helpers.list.greater(itemtype, item_stack[current_itemdepth]) then + elseif helpers.list.greater(itemtype, current_item) then local itemnum = tonumber(stringstrip(itemtype)) or helpers.list.get_decimal(itemtype) result = result .. stringformat([[ \\setnumber[itemgroup:itemize]{%s} ]], itemnum) end - item_stack[current_itemdepth] = itemtype + item_stack[#item_stack] = itemtype end return result .. [[ |