diff options
author | Philipp Gesang <phg@phi-gamma.net> | 2014-03-02 17:04:05 +0100 |
---|---|---|
committer | Philipp Gesang <phg@phi-gamma.net> | 2018-12-02 21:09:42 +0100 |
commit | 008c8958d3f19acaac24ce995ce22bb7d9636b58 (patch) | |
tree | 687db1c79717e6009ba8d38c8be6c40241e3ec93 /src | |
parent | 9f89207cca864754aaad2edd2e50b3b0bf69fd07 (diff) | |
download | context-rst-008c8958d3f19acaac24ce995ce22bb7d9636b58.tar.gz |
simplify itemization level stack handling
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 .. [[ |