Skip to content

Commit e07af11

Browse files
committed
Automatically reset bookmark level in chapter roots
Fixes #1075
1 parent 694f3c0 commit e07af11

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/resources/filters/quarto-pre/book-numbering.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ function bookNumbering()
2929
tappend(appendixPara.content, el.content)
3030
appendixPara.content:insert(pandoc.RawInline('latex', '}'))
3131
return appendixPara
32+
elseif bookItemType == "chapter" then
33+
preState.usingBookmark = true
34+
35+
local bookmarkReset = pandoc.Para({
36+
pandoc.RawInline('latex', '\\bookmarksetup{startatroot}'),
37+
})
38+
tappend(bookmarkReset.content, el.content)
39+
return bookmarkReset
3240
end
3341
end
3442

src/resources/filters/quarto-pre/meta.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ function quartoPreMetaInject()
3737
inject(usePackage("tikz"))
3838
end
3939
end)
40+
41+
42+
metaInjectLatex(meta, function(inject)
43+
if preState.usingBookmark then
44+
inject(
45+
usePackage("bookmark")
46+
)
47+
end
48+
end)
49+
4050
return meta
4151
end
4252
}

src/resources/filters/quarto-pre/quarto-pre.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ text = require 'text'
99

1010
-- global state
1111
preState = {
12+
usingBookmark = false,
1213
usingTikz = false,
1314
results = {
1415
resourceFiles = pandoc.List({}),

0 commit comments

Comments
 (0)