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
@@ -1,13 +1,13 @@
|
||||
3323be390b976ebb455bbe1eb519cde2 README.md
|
||||
edf3ece1cedee3683c33e445f8baa7a0 _extension.yml
|
||||
c7c6908b4f5396ab92c823fedf5e30c9 README.md
|
||||
1d896e28858020aa2382b6ae95563624 _extension.yml
|
||||
9037e06faf2c5fde7b3d614039652eed audit-page.js
|
||||
f6fbbba5aecc3141f06bf2aca93fccac audit.py
|
||||
a2f486f6e2dc382624f99801db209b75 calc-notes.css
|
||||
e9500e2554429fc8da7e9b2a6b51c8f1 calc-notes.js
|
||||
9522cbbd7257f1c23801ac45445c79d7 calc-notes.lua
|
||||
0ab1243f84b9e26805702bf2d6037b04 calc-notes.lua
|
||||
e380e93d24a5968cc483dcbe48d99613 exo.css
|
||||
1b1c35a5488c4e695a34b1f9efaeab4f exo.js
|
||||
b8f9d58b33f59a8706114043f77e45d8 exo.lua
|
||||
f523937255700985389163d4f28047dc exo.lua
|
||||
62e03d6d5bd4f62830d71eadb66aa5ed fenced-divs.lua
|
||||
8bd78a96d4553b922718a381d14a44a3 further.css
|
||||
0004ad931e4e0fdc443d4181516e3eb1 further.lua
|
||||
@@ -16,13 +16,15 @@ b8f9d58b33f59a8706114043f77e45d8 exo.lua
|
||||
f15c28669daddf935768611de0bf06f6 glossary.lua
|
||||
2aa159cbe6bfe1ee35e18d4290d67425 handin.sh
|
||||
93c5c7dddcc07fd7dcedcf06ff32c0d3 high-contrast.css
|
||||
cb6ce428452656a970d383cd0bc582fa history.css
|
||||
dbd8d48bb77be91bd6ff52796904538c history.lua
|
||||
691f5e66397d855e951c37a953701913 i18n.lua
|
||||
061f762946d63ea672d4f989f762baf7 latex-tables.css
|
||||
399329f7ed50a9739820c27e4813b6b5 latex-tables.lua
|
||||
b846f2c4afd59aa0c9a328c71633425f narrow.css
|
||||
21b27640373cee858ad28cd9aaa1e858 quiz.css
|
||||
d03bb30f6a18c048173c24a0bcba5e24 quiz.js
|
||||
16ef26fab71f8bb28d7764727b8fb4b4 quiz.lua
|
||||
2deed2b035216aa79617e2dcfb727102 quiz.lua
|
||||
2b8ca7ff531d30903bc41240e8b77691 si-mathjax.lua
|
||||
d32141259df2ce229400779c2ed284d9 sync.sh
|
||||
838bac386bf1e2b1e0323d91119c3632 theme.css
|
||||
|
||||
@@ -13,6 +13,7 @@ documents its syntax in the comment at its top; this page is the overview.
|
||||
| `i18n.lua` | one source, several languages: `::: {.de}`, `[…]{.fr}`, `@tr{key}` |
|
||||
| `si-mathjax.lua` | `\SI`, `\si`, `\num`, `\ang` in HTML (PDF uses siunitx) |
|
||||
| `further.lua` | `::: {.further}` purple "to go further" notes, for material beside the lecture |
|
||||
| `history.lua` | `::: {.history}` quiet grey boxes for historical context beside the text |
|
||||
| `fenced-divs.lua` | repairs `:::` divs indented deeper than pandoc accepts (in numbered parts) |
|
||||
| `theme.css` | the palette every part shares, in light and in night mode |
|
||||
| `high-contrast.css` | the high-contrast pair, after GitHub's two high-contrast VS Code themes |
|
||||
@@ -46,6 +47,7 @@ glossary-page: glossary.html
|
||||
glossary-back: "→ definition in context" # follows `lang` (en/fr/de) by default
|
||||
|
||||
high-contrast: true # stronger palette, both modes (default: off)
|
||||
field: math # study field, for the badge colour on the index (math, phys, cs, bi, …)
|
||||
```
|
||||
|
||||
## Night mode
|
||||
@@ -171,6 +173,9 @@ Statement.
|
||||
Each solution is labelled with its part ("Solution (Part 2)"). Override with
|
||||
`:::{.solution part="b"}`. Empty solutions (placeholders) are not shown.
|
||||
|
||||
Exercises and quizzes are numbered chapter.n; in an appendix the chapter is
|
||||
its letter, A.1, A.2, … (and `handin.sh A.1` hands one in).
|
||||
|
||||
## Quizzes
|
||||
|
||||
```markdown
|
||||
@@ -248,6 +253,24 @@ It renders as a purple box, headed "To go further" (following `lang`: *Vertiefun
|
||||
colour with `furthercolor:` in `_quarto.yml`. Use it whenever the handwritten
|
||||
pages carry a "to go further" annotation.
|
||||
|
||||
## Historical context
|
||||
|
||||
History beside the text — who found a result, an old paradox, how a notion
|
||||
came about — is not material to study, so it does not go in the purple
|
||||
"to go further" box (which is for optional mathematics):
|
||||
|
||||
```markdown
|
||||
::: {.history title="Achilles and the tortoise"}
|
||||
Zeno of Elea …
|
||||
:::
|
||||
```
|
||||
|
||||
It renders as a quiet grey box with an italic heading, "History" (following
|
||||
`lang`: *Geschichte*, *Histoire*; override with `history: label: "…"`), in
|
||||
the muted token, so night mode and high contrast follow by themselves. In a
|
||||
multilingual book, wrap the body in language divs and write the title as
|
||||
`title="@tr{key}"`, as for `.further`.
|
||||
|
||||
## Tools
|
||||
|
||||
**Hand in solutions.** Renders only the chosen exercises to `_handin/`, and
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
title: notes
|
||||
author: Matsune
|
||||
version: 2.9.1
|
||||
version: 2.10.0
|
||||
quarto-required: ">=1.4.0"
|
||||
contributes:
|
||||
filters:
|
||||
@@ -21,6 +21,7 @@ contributes:
|
||||
at: pre-ast
|
||||
- si-mathjax.lua
|
||||
- further.lua
|
||||
- history.lua
|
||||
- latex-tables.lua
|
||||
# post-quarto: after Quarto's crossref, so {#eq-...} labels on calc blocks
|
||||
# resolve; glossary last, so \gls{} inside a calc block is linked too
|
||||
|
||||
@@ -395,6 +395,15 @@ function Meta(m)
|
||||
stylesheets = { "theme.css", "high-contrast.css", "calc-notes.css", "narrow.css" },
|
||||
scripts = { "calc-notes.js" },
|
||||
})
|
||||
-- The book's study field (`field: math`), for the notes pipeline: the
|
||||
-- book's badge on the index takes the colour of its field.
|
||||
if m.field ~= nil then
|
||||
local field = pandoc.utils.stringify(m.field):lower()
|
||||
if field:match("^[a-z0-9%-]+$") then
|
||||
quarto.doc.include_text("in-header",
|
||||
'<meta name="notes-field" content="' .. field .. '">')
|
||||
end
|
||||
end
|
||||
-- `-src` holds the book's own colour, which theme.css lifts for a dark
|
||||
-- page rather than replacing; `-dark` is a book's explicit override.
|
||||
quarto.doc.include_text("in-header", table.concat({
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
/* history.css -- historical context: a quiet grey box with an italic heading,
|
||||
so it reads as background and not as material to study (the purple
|
||||
.further box is for optional mathematics). Colours are notes tokens only,
|
||||
so light/dark and high contrast follow by themselves. */
|
||||
|
||||
.history {
|
||||
margin: 1.1rem 0;
|
||||
padding: 0.5rem 0.9rem 0.6rem;
|
||||
border: 1px solid color-mix(in srgb, var(--calc-muted, #57606a) 30%, transparent);
|
||||
border-left: 3px double var(--calc-muted, #57606a);
|
||||
border-radius: 0.35rem;
|
||||
background: color-mix(in srgb, var(--calc-muted, #57606a) 5%, transparent);
|
||||
}
|
||||
|
||||
.history-head {
|
||||
color: var(--calc-muted, #57606a);
|
||||
font-style: italic;
|
||||
font-weight: 600;
|
||||
font-size: 0.92em;
|
||||
margin-bottom: 0.35rem;
|
||||
}
|
||||
|
||||
.history-body > p:first-child { margin-top: 0; }
|
||||
.history-body > p:last-child { margin-bottom: 0; }
|
||||
|
||||
/* keep wide content inside the box, as .further does */
|
||||
.history mjx-container[display="true"] {
|
||||
max-width: 100%;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
padding-bottom: 0.35em;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
justify-content: safe center;
|
||||
}
|
||||
.history :is(pre, table) { max-width: 100%; overflow-x: auto; }
|
||||
.history img, .history svg { max-width: 100%; }
|
||||
|
||||
html.hc .history { border-color: var(--calc-ink, #1a1a1a); }
|
||||
@@ -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("&", "&"):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",
|
||||
'<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 },
|
||||
}
|
||||
@@ -512,6 +512,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 quizzes 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
|
||||
@@ -520,7 +542,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
|
||||
@@ -529,6 +554,7 @@ end
|
||||
local function walk(doc)
|
||||
local is_latex, is_html = fmt_is("latex"), fmt_is("html")
|
||||
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 pending = {}
|
||||
local out = pandoc.Blocks({})
|
||||
@@ -546,6 +572,9 @@ local function walk(doc)
|
||||
if marker ~= nil then
|
||||
if is_latex then flush() end
|
||||
next_number = chapter_label(marker.bookItemNumber)
|
||||
if next_number ~= nil and appendices[basename(marker.bookItemFile)] 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