Night-mode styling, French cross-references, and the log through Part VI

- theme.scss and figures draw with the extension's --calc-… tokens; light/dark
  pair plus the high-contrast button; a11y highlight style for html
- figure labels split so none leaves its viewBox in any language
- _quarto-fr.yml: French cross-reference prefixes
- notes extension synced to 2.8.18
- conv/: Parts IV, V and VI logged, pasted terminal output redacted

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
MatsuneMikuroiandClaude Opus 5 committed 2026-10-06 03:36:51 +02:00
1 parent afb816f459
commit f7fa60ba81
62 files changed
+3552 -852

No files matched your search

+59 -24
View File
@@ -29,6 +29,7 @@
--
-- Usage (works for entries and properties):
-- in math: \gls{laplacian} \gls{laplacian.linearity}
-- \gls[\nabla^2 g]{laplacian} (shows a variant, links to the entry)
-- in prose: [laplacian]{.gls} [by linearity]{.gls key=laplacian.linearity}
-- the list: ::: {.glossary}\n:::
--
@@ -330,7 +331,11 @@ local function register_inline(el)
if b.t == "Div" and b.classes:includes("gls-prop") then
local pk = b.attributes.key
if pk == nil then
io.stderr:write("[glossary] .gls-prop without key= (in " .. key .. ")\n")
-- keep the text: it stays in the definition, unlisted as a property
io.stderr:write("[glossary] WARNING: .gls-prop without key= in '" .. key
.. "': its text is kept in the definition but is not listed as a"
.. " property; add key=<name> to list it\n")
entry.def:extend(b.content)
else
entry.props[pk] = {
sym = math_of_attr(b.attributes.symbol),
@@ -356,21 +361,30 @@ end
------------------------------------------------------------------ pass 3: usages & rendering
-- rewrite \gls{...} occurrences inside a TeX/math string
-- rewrite \gls{key} and \gls[shown]{key} occurrences inside a TeX/math
-- string. The optional [shown] is what the formula displays instead of the
-- entry's own symbol -- a variant of it, M_{n \times p}(\mathbb{K}) for the
-- entry M_{m \times n}(\mathbb{K}) -- and it links to the entry all the same.
local function gls_link(key, shown, target)
local r = resolve(key)
if r == nil then
warn_key(key)
return "\\text{??" .. key .. "??}"
end
local disp = shown or math_display(r)
if target == "latex" then
-- \protect: a link may sit in a moving argument (a figure caption)
return "\\protect\\hyperlink{" .. r.id .. "}{" .. disp .. "}"
end
return "\\href{" .. r.href .. "}{\\class{gls-sym gls-key-" .. key .. "}{" .. disp .. "}}"
end
local function replace_gls(txt, target)
txt = txt:gsub("\\gls%s*(%b[])%s*(%b{})", function(bracketed, braced)
return gls_link(braced:sub(2, -2), bracketed:sub(2, -2), target)
end)
return (txt:gsub("\\gls(%b{})", function(braced)
local key = braced:sub(2, -2)
local r = resolve(key)
if r == nil then
warn_key(key)
return "\\text{??" .. key .. "??}"
end
local disp = math_display(r)
if target == "latex" then
return "\\hyperlink{" .. r.id .. "}{" .. disp .. "}"
else
return "\\href{" .. r.href .. "}{\\class{gls-sym gls-key-" .. key .. "}{" .. disp .. "}}"
end
return gls_link(braced:sub(2, -2), nil, target)
end))
end
@@ -397,7 +411,7 @@ local function usage(key, display)
end
local out = pandoc.Inlines({})
if fmt_is("latex") then
out:insert(pandoc.RawInline("latex", "\\hyperlink{" .. r.id .. "}{"))
out:insert(pandoc.RawInline("latex", "\\protect\\hyperlink{" .. r.id .. "}{"))
out:extend(display)
out:insert(pandoc.RawInline("latex", "}"))
elseif fmt_is("html") then
@@ -436,6 +450,8 @@ end
local function RawInline(el)
if el.format ~= "tex" and el.format ~= "latex" then return nil end
-- (no [shown] form here: pandoc reads \gls[..]{..} in prose as plain text,
-- never as raw tex; a variant in prose is [$...$]{.gls key=...})
local key = el.text:match("^\\gls%s*{(.-)}$")
if key == nil then return nil end
local r = resolve(key)
@@ -443,6 +459,15 @@ local function RawInline(el)
return usage(key, pandoc.Inlines({ pandoc.Math("InlineMath", math_display(r)) }))
end
-- A definition is stored in pass 2, before its own usages are resolved: run
-- them on the stored copy wherever it is shown (in place, in the list, in
-- the tooltip data and the cross-file cache), or a \gls{..} / [..]{.gls}
-- written inside a definition would come out unresolved.
local function resolved(blocks)
if blocks == nil then return blocks end
return blocks:walk({ Math = Math, RawBlock = RawBlock, RawInline = RawInline, Span = Span })
end
-- head line "sym — **term**" (+ latex hypertarget when with_anchor)
local function head_line(id, sym, term, with_anchor)
local head = pandoc.Inlines({})
@@ -460,7 +485,7 @@ end
local function prop_div(base, pk, p, with_anchor)
local id = anchor(base .. "." .. pk)
local blocks = pandoc.Blocks({ head_line(id, p.sym, p.term, with_anchor) })
blocks:extend(p.def:clone())
blocks:extend(resolved(p.def:clone()))
return pandoc.Div(blocks,
pandoc.Attr(with_anchor and id or "", { "gls-entry", "gls-prop-entry" }))
end
@@ -473,7 +498,7 @@ local function render_inline_def(el)
if e == nil or not e.inline then return nil end
local id = anchor(key)
local blocks = pandoc.Blocks({ head_line(id, e.sym, e.term, true) })
blocks:extend(e.def:clone())
blocks:extend(resolved(e.def:clone()))
for _, pk in ipairs(e.porder) do
if not e.props[pk].standalone then -- standalone props render at their own spot
blocks:insert(prop_div(key, pk, e.props[pk], true))
@@ -493,7 +518,7 @@ local function render_list(el)
-- the list clone links back instead of re-anchoring
local with_anchor = not e.inline
local entry = pandoc.Blocks({ head_line(id, e.sym, e.term, with_anchor) })
entry:extend(e.def:clone())
entry:extend(resolved(e.def:clone()))
if e.inline then
for _, pk in ipairs(e.porder) do
local p = e.props[pk]
@@ -610,11 +635,11 @@ local function write_cache()
for pk, p in pairs(e.props) do
props[pk] = { sym = p.sym,
term = pandoc.utils.stringify(p.term),
def_html = blocks_to_html(p.def) }
def_html = blocks_to_html(resolved(p.def)) }
end
entries[key] = { sym = e.sym,
term = pandoc.utils.stringify(e.term),
def_html = blocks_to_html(e.def),
def_html = blocks_to_html(resolved(e.def)),
page = current_page,
props = props }
end
@@ -645,13 +670,23 @@ local function inject_data(doc)
if not fmt_is("html") then return doc end
write_cache()
if quarto == nil or quarto.doc == nil then return doc end
-- in sorted order: pairs() walks a table in a different order on every
-- run, which rewrote every page of a book on each rebuild
local function sorted_keys(t)
local ks = {}
for k in pairs(t) do ks[#ks + 1] = k end
table.sort(ks)
return ks
end
local parts = {}
for key, e in pairs(glossary) do
for _, key in ipairs(sorted_keys(glossary)) do
local e = glossary[key]
parts[#parts + 1] = '"' .. js_escape(key) .. '":"'
.. js_escape(head_html(e.sym, e.term) .. blocks_to_html(e.def)) .. '"'
for pk, p in pairs(e.props) do
.. js_escape(head_html(e.sym, e.term) .. blocks_to_html(resolved(e.def))) .. '"'
for _, pk in ipairs(sorted_keys(e.props)) do
local p = e.props[pk]
parts[#parts + 1] = '"' .. js_escape(key .. "." .. pk) .. '":"'
.. js_escape(head_html(p.sym, p.term) .. blocks_to_html(p.def)) .. '"'
.. js_escape(head_html(p.sym, p.term) .. blocks_to_html(resolved(p.def))) .. '"'
end
end
if #parts == 0 then return doc end