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:
MatsuneMikuroiandClaude Opus 5.5 committed 2026-10-16 23:59:30 +02:00
1 parent f047b9c7ae
commit d74a2e90b4
88 files changed
+874 -437

No files matched your search

+117
View File
@@ -0,0 +1,117 @@
-- history.lua — historical context beside the text, not material to study
--
-- ::: {.history}
-- Zeno's paradox of Achilles and the tortoise ...
-- :::
--
-- ::: {.history title="Achilles and the tortoise"}
-- ...
-- :::
--
-- A quiet grey box with an italic heading, so it reads as background; the
-- purple .further box stays for optional mathematics. HTML: a box with a
-- heading, coloured from the notes tokens (history.css). PDF: a tcolorbox in
-- the same grey. From Analysis (2026-10-16).
--
-- Metadata:
-- history:
-- label: "Histoire" # defaults to the document `lang`
local LABELS = {
en = "History",
fr = "Histoire",
de = "Geschichte",
}
local GREY = "57606A" -- --calc-muted of the light theme
local label = LABELS.en
local function fmt_is(name)
if quarto and quarto.doc and quarto.doc.is_format then
return quarto.doc.is_format(name)
end
return FORMAT ~= nil and FORMAT:match(name) ~= nil
end
local function str(v)
if v == nil then return nil end
if type(v) == "boolean" then return tostring(v) end
return pandoc.utils.stringify(v)
end
local function esc_html(s)
return (s:gsub("&", "&amp;"):gsub("<", "&lt;"):gsub(">", "&gt;"):gsub('"', "&quot;"))
end
local function read_meta(meta)
local lang = (str(meta.lang) or "en"):lower():gsub("[_-].*$", "")
label = LABELS[lang] or LABELS.en
if type(meta.history) == "table" and meta.history.label ~= nil then
label = str(meta.history.label)
end
if quarto ~= nil and quarto.doc ~= nil then
if fmt_is("html") then
quarto.doc.add_html_dependency({
name = "calc-history",
version = dofile(quarto.utils.resolve_path("version.lua")),
stylesheets = { "history.css" },
})
elseif fmt_is("latex") then
-- same options as Quarto's callouts, so the two never clash
quarto.doc.use_latex_package("tcolorbox", "skins,breakable")
quarto.doc.use_latex_package("xcolor")
quarto.doc.include_text("in-header", "\\definecolor{historycolor}{HTML}{" .. GREY .. "}")
end
end
return meta
end
------------------------------------------------------------------ render
-- `sep`: what goes between the label and a title= of its own. LaTeX fonts
-- often lack the U+2002 glyph, so the pdf gets \enspace instead.
local function head_text(el, sep)
local title = el.attributes.title
if title ~= nil and title ~= "" then
return label .. (sep or "\u{2002}—\u{2002}") .. title
end
return label
end
local function html_box(el)
local blocks = pandoc.Blocks({ pandoc.RawBlock("html",
'<div class="history"><div class="history-head">'
.. esc_html(head_text(el)) .. '</div><div class="history-body">') })
blocks:extend(el.content)
blocks:insert(pandoc.RawBlock("html", "</div></div>"))
return blocks
end
local function latex_box(el)
local blocks = pandoc.Blocks({ pandoc.RawBlock("latex",
"\\begin{tcolorbox}[enhanced jigsaw,breakable,"
.. "colback=historycolor!3!white,colframe=historycolor!40!white,"
.. "boxrule=0.4pt,arc=1pt,colbacktitle=historycolor!10!white,"
.. "coltitle=historycolor!85!black,fonttitle=\\small\\itshape,"
.. "title={" .. head_text(el, "\\enspace---\\enspace{}") .. "},"
.. "left=2mm,right=1.5mm,top=1mm,bottom=1mm]") })
blocks:extend(el.content)
blocks:insert(pandoc.RawBlock("latex", "\\end{tcolorbox}"))
return blocks
end
local function Div(el)
if not el.classes:includes("history") then return nil end
if fmt_is("html") then return html_box(el) end
if fmt_is("latex") then return latex_box(el) end
-- any other format: a plain titled block
local blocks = pandoc.Blocks({
pandoc.Para({ pandoc.Emph({ pandoc.Str(head_text(el) .. ".") }) }) })
blocks:extend(el.content)
return pandoc.Div(blocks, pandoc.Attr("", { "history" }))
end
return {
{ Meta = read_meta },
{ Div = Div },
}