This commit is contained in:
Jean-Marie 'Histausse' Mineau 2026-05-31 16:11:55 +02:00
parent 38a192abb6
commit 7e8ee9d17e
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
3 changed files with 68 additions and 8 deletions

View file

@ -2,15 +2,26 @@
#let state-pyscript-version = state("state-pyscript-version", none)
#let state-pyscript-headers = state("state-pyscript-headers", (:))
#let pyscript(body) = {
#let pyscript(
repl: false,
body
) = {
show raw.where(block: true, lang: "python"): it => {
state-use-pyscript.update(x => true)
it
html.elem("script", attrs: (
type: "py",
terminal: "",
worker: "",
), it.text)
let script = it.text;
if repl {
script = "import code\n" + script + "\ncode.interact(local=globals())"
}
html.elem(
"script",
attrs: (
type: "py",
terminal: "",
worker: "",
),
script
)
}
body
}