API Reference#
The reference is generated from the /// comments in the source. It covers the public rendering API in libs/scratch/api.typ, which lib.typ and package.typ re-export unchanged.
blockly#
blockly(
text,
profile: auto,
language: auto,
theme: auto,
scale: auto,
font: auto,
line-numbering: auto,
line-numbers: auto,
line-number-start: auto,
line-number-first-block: auto,
line-number-gutter: auto,
inset-scale: auto,
colors: auto,
)Render Blockly blocks from text. Same notation as scratch(), drawn with Blockly’s shapes — notch, puzzle tab, boxed fields — and the vocabulary, categories and colours of a profile:
"blockly"(the default): today’s flat look, Blockly’s German wording"blockly-klassisch": the pre-2019 look"jwinf": jwinf.de — classic geometry, the robot and turtle world blocks, and the palette of the robot training tasks"jwinf-turtle": the same with the colours of the Freie Turtle-Umgebung
colors: (logik: "#73cc47") overrides single categories of any profile.
Labels that no profile knows are drawn as written, with the category taken from a ::kategorie suffix — on jwinf the normal case, because the same block reads differently from task to task.
#blockly("wiederhole (4) mal:\n gehe nach rechts\nende", profile: "jwinf")| Name | Vorgabe |
|---|---|
text | – |
profile | auto |
language | auto |
theme | auto |
scale | auto |
font | auto |
line-numbering | auto |
line-numbers | auto |
line-number-start | auto |
line-number-first-block | auto |
line-number-gutter | auto |
inset-scale | auto |
colors | auto |
blockly-parse#
blockly-parse(text, language: "de", profile: "blockly")| Name | Vorgabe |
|---|---|
text | – |
language | "de" |
profile | "blockly" |
blockst#
blockst(
theme: auto,
scale: auto,
font: auto,
line-numbering: auto,
line-numbers: auto,
line-number-start: auto,
line-number-first-block: auto,
line-number-gutter: auto,
inset-scale: auto,
language: auto,
colors: auto,
spacing: 1.5em,
body,
)| Name | Vorgabe |
|---|---|
theme | auto |
scale | auto |
font | auto |
line-numbering | auto |
line-numbers | auto |
line-number-start | auto |
line-number-first-block | auto |
line-number-gutter | auto |
inset-scale | auto |
language | auto |
colors | auto |
spacing | 1.5em |
body | – |
blockst-labels#
blockst-labels(name)scratch() blocks. With a name: #blockst-labels("start", default: "?"). Without a name: returns the full label-to-line dictionary.blockst-register-labels#
blockst-register-labels(text, language: "en")#scratch() output appears.| Name | Vorgabe |
|---|---|
text | – |
language | "en" |
makecode#
makecode(
text,
profile: auto,
language: auto,
theme: auto,
scale: auto,
font: auto,
line-numbering: auto,
line-numbers: auto,
line-number-start: auto,
line-number-first-block: auto,
line-number-gutter: auto,
inset-scale: auto,
colors: auto,
)Render MakeCode blocks from text — the micro:bit and Calliope mini editors’ look: Blockly’s zelos renderer with MakeCode’s monospace labels. Same notation as scratch(); (…) is a value, [… v] a dropdown, <…> a boolean, ende/end closes a C-block and sonst/else opens the else branch. The profile picks the target: "makecode" (micro:bit, the default) or "makecode-calliope"; the language is any of the editors’ 36 ("de" by default, "en", "fr", "es", "zh-cn", …), with the block texts the editors show in that language. The end marker follows the language (ende, end, fin, …); end and ende work in every language.
#makecode("beim Start\n zeige Zahl (0)\nende")| Name | Vorgabe |
|---|---|
text | – |
profile | auto |
language | auto |
theme | auto |
scale | auto |
font | auto |
line-numbering | auto |
line-numbers | auto |
line-number-start | auto |
line-number-first-block | auto |
line-number-gutter | auto |
inset-scale | auto |
colors | auto |
makecode-parse#
makecode-parse(text, language: "de", profile: "makecode")| Name | Vorgabe |
|---|---|
text | – |
language | "de" |
profile | "makecode" |
raw-blockly#
raw-blockly(..args)Enable Blockly code blocks in raw text:
#show: raw-blockly()
```blockly
wiederhole (4) mal:
ende
```A jwinf fence uses the jwinf profile whatever the arguments say, a jwinf-turtle fence the turtle sandbox’s colours.
raw-makecode#
raw-makecode(..args)Enable MakeCode code blocks in raw text:
#show: raw-makecode()
```makecode
beim Start
zeige Zahl (0)
ende
```A microbit fence is the same; a calliope fence uses the Calliope mini profile whatever the arguments say.
raw-scratch#
raw-scratch(..args)Enable scratch code blocks in raw text:
#show: raw-scratch()With language: #show: raw-scratch(language: "de").
scratch#
scratch(
text,
language: auto,
theme: auto,
scale: auto,
font: auto,
line-numbering: auto,
line-numbers: auto,
line-number-start: auto,
line-number-first-block: auto,
line-number-gutter: auto,
inset-scale: auto,
colors: auto,
)#blockst[...]. Supports 26 languages: en, de, fr, es, it, pt, nl, pl, ru, ja, …| Name | Vorgabe |
|---|---|
text | – |
language | auto |
theme | auto |
scale | auto |
font | auto |
line-numbering | auto |
line-numbers | auto |
line-number-start | auto |
line-number-first-block | auto |
line-number-gutter | auto |
inset-scale | auto |
colors | auto |
scratch-execute#
scratch-execute(text, language: "en")| Name | Vorgabe |
|---|---|
text | – |
language | "en" |
scratch-labels#
scratch-labels(text, language: "en")#labels to rendered line numbers.| Name | Vorgabe |
|---|---|
text | – |
language | "en" |
scratch-parse#
scratch-parse(text, language: "en")| Name | Vorgabe |
|---|---|
text | – |
language | "en" |
set-blockst#
set-blockst(
theme: none,
profile: none,
colors: none,
scale: none,
stroke-width: none,
font: none,
line-numbering: none,
line-numbers: none,
line-number-start: none,
line-number-first-block: none,
line-number-gutter: none,
inset-scale: none,
language: none,
)Global settings applied to all scratch() and sb3 calls.
colors lays the document’s own category colours over the profile’s palette: set-blockst(colors: (logik: "#73cc47")) — a hex string or a Typst colour per category. The shades a theme derives (bevel, stroke, high-contrast, grayscale) follow the new fill.
| Name | Vorgabe |
|---|---|
theme | none |
profile | none |
colors | none |
scale | none |
stroke-width | none |
font | none |
line-numbering | none |
line-numbers | none |
line-number-start | none |
line-number-first-block | none |
line-number-gutter | none |
inset-scale | none |
language | none |