summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/strc-bkm.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/strc-bkm.lua')
-rw-r--r--Master/texmf-dist/tex/context/base/strc-bkm.lua82
1 files changed, 77 insertions, 5 deletions
diff --git a/Master/texmf-dist/tex/context/base/strc-bkm.lua b/Master/texmf-dist/tex/context/base/strc-bkm.lua
index d9c268ce4d9..c38ab3c2e8c 100644
--- a/Master/texmf-dist/tex/context/base/strc-bkm.lua
+++ b/Master/texmf-dist/tex/context/base/strc-bkm.lua
@@ -85,7 +85,7 @@ end
local function stripped(str) -- kind of generic
str = gsub(str,"\\([A-Z]+)","%1") -- \LOGO
str = gsub(str,"\\ "," ") -- \
- str = gsub(str,"\\([A-Za-z]+) *{(.-)}","%1") -- \bla{...}
+ str = gsub(str,"\\([A-Za-z]+) *{(.-)}","%2") -- \bla{...}
str = gsub(str," +"," ") -- spaces
return str
end
@@ -101,11 +101,65 @@ function bookmarks.setup(spec)
end
end
+-- function bookmarks.place()
+-- if next(names) then
+-- local list = lists.filtercollected(names,"all",nil,lists.collected,forced)
+-- if #list > 0 then
+-- local levels, noflevels, lastlevel = { }, 0, 1
+-- for i=1,#list do
+-- local li = list[i]
+-- local metadata = li.metadata
+-- local name = metadata.name
+-- if not metadata.nolist or forced[name] then -- and levelmap[name] then
+-- local titledata = li.titledata
+-- if titledata then
+-- local structural = levelmap[name]
+-- lastlevel = structural or lastlevel
+-- local title = titledata.bookmark
+-- if not title or title == "" then
+-- -- We could typeset the title and then convert it.
+-- if not structural then
+-- -- placeholder, todo: bookmarklabel
+-- title = name .. ": " .. (titledata.title or "?")
+-- else
+-- title = titledata.title or "?"
+-- end
+-- end
+-- if numbered[name] then
+-- local sectiondata = sections.collected[li.references.section]
+-- local numberdata = li.numberdata
+-- if sectiondata and numberdata and not numberdata.hidenumber then
+-- -- we could typeset the number and convert it
+-- title = concat(sections.typesetnumber(sectiondata,"direct",numberspec,sectiondata)) .. " " .. title
+-- end
+-- end
+-- noflevels = noflevels + 1
+-- levels[noflevels] = {
+-- lastlevel,
+-- stripped(title), -- can be replaced by converter
+-- li.references, -- has internal and realpage
+-- allopen or opened[name]
+-- }
+-- end
+-- end
+-- end
+-- bookmarks.finalize(levels)
+-- end
+-- function bookmarks.place() end -- prevent second run
+-- end
+-- end
+
function bookmarks.place()
if next(names) then
- local list = lists.filtercollected(names,"all",nil,lists.collected,forced)
- if #list > 0 then
- local levels, noflevels, lastlevel = { }, 0, 1
+ local levels = { }
+ local noflevels = 0
+ local lastlevel = 1
+ local nofblocks = #lists.sectionblocks -- always >= 1
+ local showblocktitle = toboolean(numberspec.showblocktitle,true)
+ for i=1,nofblocks do
+ local block = lists.sectionblocks[i]
+ local blockdone = nofblocks == 1
+ local list = lists.filtercollected(names,block..":all",nil,lists.collected,forced)
for i=1,#list do
local li = list[i]
local metadata = li.metadata
@@ -113,8 +167,26 @@ function bookmarks.place()
if not metadata.nolist or forced[name] then -- and levelmap[name] then
local titledata = li.titledata
if titledata then
+ if not blockdone then
+ if showblocktitle then
+ -- add block entry
+ local blockdata = sections.sectionblockdata[block]
+ noflevels = noflevels + 1
+ levels[noflevels] = {
+ 1, -- toplevel
+ stripped(blockdata.bookmark ~= "" and blockdata.bookmark or block),
+ li.references,
+ allopen or opened[name] -- same as first entry
+ }
+ end
+ blockdone = true
+ end
local structural = levelmap[name]
lastlevel = structural or lastlevel
+ if nofblocks > 1 then
+ -- we have a block so increase the level
+ lastlevel = lastlevel + 1
+ end
local title = titledata.bookmark
if not title or title == "" then
-- We could typeset the title and then convert it.
@@ -143,8 +215,8 @@ function bookmarks.place()
end
end
end
- bookmarks.finalize(levels)
end
+ bookmarks.finalize(levels)
function bookmarks.place() end -- prevent second run
end
end