add repl
This commit is contained in:
parent
38a192abb6
commit
7e8ee9d17e
3 changed files with 68 additions and 8 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue