-- 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("&", "&"):gsub("<", "<"):gsub(">", ">"):gsub('"', """)) 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", '