start migration to bundle format

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2026-06-17 12:40:20 +02:00
parent 64e270a868
commit 7fe9b99535
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
13 changed files with 378 additions and 470 deletions

57
lib/states.typ Normal file
View file

@ -0,0 +1,57 @@
// Pyscript
#let state-use-pyscript = state("state-use-pyscript", false)
#let state-pyscript-version = state("state-pyscript-version", none)
#let state-pyscript-data-list = state("state-pyscript-data-list", (:))
#let state-pyscript-interpreters = state("state-pyscript-interpreters", (:))
#let state-pyscript-default-interpreter = state("state-pyscript-default-interpreter", none)
#let state-pyscript-canvas-ids = state("state-pyscript-canvas-ids", ())
#let reset-pyscript-page-states() = {
state-use-pyscript.update(x => false)
state-pyscript-version.update(x => state-pyscript-version)
state-pyscript-data-list.update(x => (:))
state-pyscript-interpreters.update(x => (:))
state-pyscript-default-interpreter.update(x => none)
state-pyscript-canvas-ids.update(x => ())
}
// CSS / JS / misc tags
#let current-page-label = state("current-page-label", none)
#let css-list = state("css-list", ())
#let js-list = state("js-list", ())
#let additionnal-head-tags = state("additionnal-head-tags", ())
/// Add string `css` to `css-list` if not already present
#let add-css(css) = context {
css-list.update(x => if css in x { x } else { x + (css,) })
}
/// Add string `js` to `js-list` if not already present
#let add-js(js) = context {
js-list.update(x => if js in x { x } else { x + (js,) })
}
/// Add additionnal html tag to insert in <head>
#let add-tag-in-head(tag) = context {
additionnal-head-tags.update(x => if tag in x { x } else { x + (tag, ) })
}
/// Concatenate all css found in css-list at the end of the document
#let get-css(page-label) = context {
html.style(css-list.at(label(str(page-label) + "-end")).join("\n\n"))
}
/// Concatenate all js found in js-list at the end of the document
#let get-js(page-label) = context {
html.script(js-list.at(label(str(page-label) + "-end")).join("\n\n"))
}
#let reset-page-states() = {
current-page-label.update(x => none)
css-list.update(x => ())
js-list.update(x => ())
additionnal-head-tags.update(x => ())
reset-pyscript-page-states()
}