Extension 2.10.0, study field, German "Abschnitt" for sections; rebuild
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f047b9c7ae
commit
d74a2e90b4
88 files changed
+874
-437
No files matched your search
@@ -480,6 +480,28 @@ local function chapter_label(n)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Quarto numbers appendices 1, 2, ... like chapters, while the book shows
|
||||
-- them as A, B, ...: the files after the render list's "appendix" divider
|
||||
-- are appendices, and their exercises are A.1, A.2, ...
|
||||
local function appendix_files(meta)
|
||||
local set, after = {}, false
|
||||
if meta.book == nil or meta.book.render == nil then return set end
|
||||
for _, item in ipairs(meta.book.render) do
|
||||
if str(item.type) == "appendix" then
|
||||
after = true
|
||||
elseif after and item.file ~= nil then
|
||||
set[basename(str(item.file))] = true
|
||||
end
|
||||
end
|
||||
return set
|
||||
end
|
||||
|
||||
local function appendix_letter(n)
|
||||
local k = tonumber(n)
|
||||
if k == nil or k < 1 or k > 26 then return n end
|
||||
return string.char(64 + math.floor(k))
|
||||
end
|
||||
|
||||
-- HTML books render one chapter per run: its number comes from the book
|
||||
local function book_number_of_input(meta)
|
||||
if quarto == nil or quarto.doc == nil or quarto.doc.input_file == nil then return nil end
|
||||
@@ -488,7 +510,10 @@ local function book_number_of_input(meta)
|
||||
for _, item in ipairs(meta.book.render) do
|
||||
local file = str(item.file)
|
||||
if file ~= nil and (input == file or input:sub(-#file - 1) == "/" .. file) then
|
||||
return item.number ~= nil and str(item.number) or nil
|
||||
if item.number == nil then return nil end
|
||||
local n = str(item.number)
|
||||
if appendix_files(meta)[basename(file)] then n = appendix_letter(n) end
|
||||
return n
|
||||
end
|
||||
end
|
||||
return nil
|
||||
@@ -501,6 +526,7 @@ local function walk(doc)
|
||||
-- title): its number comes from the book. The merged PDF source has all
|
||||
-- the titles, each after a marker carrying its number.
|
||||
local next_number = book_number_of_input(doc.meta)
|
||||
local appendices = appendix_files(doc.meta)
|
||||
local chapter, chapter_n, cnt = next_number, tonumber(next_number) or 0, 0
|
||||
local file = quarto and quarto.doc and basename(quarto.doc.input_file) or nil
|
||||
local pending, reports, matched, nums = {}, {}, {}, {}
|
||||
@@ -529,6 +555,7 @@ local function walk(doc)
|
||||
if is_latex then flush() end
|
||||
file = basename(marker.bookItemFile)
|
||||
next_number = chapter_label(marker.bookItemNumber)
|
||||
if next_number ~= nil and appendices[file] then next_number = appendix_letter(next_number) end
|
||||
chapter, cnt = nil, 0
|
||||
out:insert(b)
|
||||
elseif b.t == "Header" and b.level == 1 then
|
||||
|
||||
Reference in new issue
Block a user