summaryrefslogtreecommitdiff
path: root/rst_context.lua
diff options
context:
space:
mode:
Diffstat (limited to 'rst_context.lua')
-rw-r--r--rst_context.lua25
1 files changed, 21 insertions, 4 deletions
diff --git a/rst_context.lua b/rst_context.lua
index 71e9e09..80bbd3b 100644
--- a/rst_context.lua
+++ b/rst_context.lua
@@ -568,7 +568,7 @@ local enumeration_types = {
["‣"] = "*",
["⁃"] = "*",
- ["#"] = "1", -- numbered lists and conversion
+ ["#"] = "n", -- numbered lists and conversion
["A"] = "A",
["a"] = "a",
["I"] = "R",
@@ -580,7 +580,9 @@ local enumeration_types = {
local stripme = S"()."
local dontstrip = 1 - stripme
local itemstripper = stripme^0 * C(dontstrip^1) * stripme^0
+
local function parse_itemstring(str)
+ local offset = nil
local setup = ",fit][itemalign=flushright,"
-- string.match is slightly faster than string.find
if str:match("^%(") then
@@ -590,16 +592,23 @@ local function parse_itemstring(str)
setup = setup .. [[right=)]]
end
if str:match("%.$") then
- setup = setup .. [[stopper=.]]
+ setup = setup .. [[stopper={.\\space}]]
end
setup = setup
str = itemstripper:match(str)
- return {setup = setup, str=str}
+ str = enumeration_types[str] or str
+ if str:match("^%d") then
+ offset = tonumber(str:match("^%d+")) - 1
+ str = "n"
+ end
+ return {setup = setup, str = str, offset = offset}
end
function rst_context.startitemize(str)
local setup = ""
+ local result = ""
+ local offset
str = string.strip(str)
local listtype = enumeration_types[str] or parse_itemstring(str)
@@ -607,12 +616,20 @@ function rst_context.startitemize(str)
if type(listtype) == "table" then
--print(type(listtype), listtype[2])
setup = listtype.setup
+ offset = listtype.offset
listtype = listtype.str
end
- return [[
+ result = [[
\\startitemize[]] .. listtype .. setup .. [[]
]]
+ if offset then
+ result = result .. [[
+
+\\setnumber[itemgroup:itemize]{]] .. offset .. [[}
+]]
+ end
+ return result
end
function rst_context.stopitemize(str)