PDF

blockstblockst0.4.0

Render Scratch, Blockly, MakeCode and Open Roberta blocks for educational documents.

Labels and line numbers#

A line that ends in #name is labelled. Labels are collected from every rendered block group — Scratch, Blockly, MakeCode — and can be queried later, so a worksheet can say „the loop in line 3“ and be right after the program changes.

blockst-labels() — Query Labels#

#blockst-labels("loop")   // → line number or "NaN"
#blockst-labels()         // → full label → line dictionary

scratch-labels() — Extract Labels#

Parses Scratch text and returns a dictionary mapping label names to line numbers, without rendering.

#let labels = scratch-labels("
repeat (4) #loop
  move (20) steps #step
  turn cw (90) degrees
end
")
// labels = ("loop": 1, "step": 2)

blockst-register-labels() — Pre-register Labels#

Registers labels globally without rendering blocks — for labels that are needed before the first block output.

#blockst-register-labels("
repeat (4) #loop
  move (20) steps #step
end
")