69 lines
1.5 KiB
Typst
69 lines
1.5 KiB
Typst
#let callout(kind: str, label: str, body) = context if target() == "html" {
|
|
html.section(class: kind + " callout", context {
|
|
let depth = counter(heading).at(here()).len() + 1
|
|
heading(
|
|
depth: depth,
|
|
outlined: false,
|
|
numbering: none,
|
|
label,
|
|
)
|
|
" "
|
|
body
|
|
})
|
|
} else {
|
|
let col = (
|
|
note: color.rgb("#0000cd"),
|
|
warn: color.rgb("#a52a2a"),
|
|
tip: color.rgb("#228b22"),
|
|
todo: color.rgb("#ff0000"),
|
|
).at(kind)
|
|
block(
|
|
fill: col.transparentize(85%),
|
|
stroke: (y: col),
|
|
width: 100%,
|
|
outset: (x: 1em, y: 0.5em),
|
|
spacing: par.spacing + 0.5em,
|
|
inset: (y: 0.5em),
|
|
{
|
|
set text(fill: col)
|
|
strong(label)
|
|
body
|
|
},
|
|
)
|
|
}
|
|
|
|
|
|
#let note = callout.with(kind: "note", label: "Note:")
|
|
#let warn = callout.with(kind: "warn", label: "Warning:")
|
|
#let tip = callout.with(kind: "tip", label: "Tip:")
|
|
|
|
// #let todo = callout.with(kind: "todo", label: "TODO:")
|
|
#let todo(caption, ..args) = callout(kind: "todo", label: "TODO:", {
|
|
show figure: none
|
|
(
|
|
caption,
|
|
figure(kind: "todo", supplement: "TODO", caption: caption, none),
|
|
..args.pos(),
|
|
).join(parbreak())
|
|
})
|
|
|
|
|
|
#let example = callout.with(kind: "eg", label: "For example:")
|
|
|
|
#let details(body, label: "Details", open: false) = {
|
|
context if target() == "html" {
|
|
html.details(open: open, {
|
|
html.summary(strong[Click for #label])
|
|
body
|
|
})
|
|
} else {
|
|
[
|
|
#strong(label):
|
|
#body
|
|
]
|
|
}
|
|
}
|
|
|
|
// #let solution = details.with(label: "Solution")
|
|
#let solution = callout.with(kind: "solution", label: "Solution:")
|