Jump to content

Extension:Snapblocks

From mediawiki.org
MediaWiki extensions manual
Snapblocks
Release status: stable
Implementation Tag
Description Create Snap! blocks from text.
Author(s) ego-lay-atman-bay and R4356th
Latest version 1.3.1
MediaWiki
License MIT License
Download
snapblocks, scratchblocks, sb

Snapblocks is an extension to display blocks from the Snap! programming language created by Jens MĂśnig and Brian Harvey in wiki articles. It is also a fork of the ScratchBlocks extension.

$wgSnapBlocksLangs = ['ja', 'zh_TW'];

Installation

[edit]

Configuration

[edit]

By default, only English Snap! blocks are rendered. Add more languages like so:

Note: currently translations are somewhat broken, and only include Scratch primitives. Note that the TW is preceded by an underscore, not a hyphen. This variable is accessible through JS mw.config.get("wgSnapBlocksLangs")

Usage

[edit]

There are three ways to create a snippet of Snap! blocks, which are nearly identical.

  • Use <snapblocks> before and after your code to create a block level element displaying Snap code.
  • Use <scratchblocks> before and after your code to create a block level element displaying Snap! code. This is kept from the ScratchBlocks extension, in order to make transitioning to Snapblocks easier.
  • To create an inline-block element (that will show in the middle of the paragraph), enclose the code in <sb> tags.
<snapblocks>
repeat (5) {
  move (10) steps
}
say [Done!]
</snapblocks>
You can map over a list in Snap! with the <sb>(map (() @addInput) over @list)</sb> block.

All three tags take a version attribute, whose default value is snap. If specified as 2 or 3, the tag will render its blocks in Scratch 2.0 or 3.0 style respectively. You can also specify hc-3 for the Scratch 3.0 high contrast style, and snap-flat for the Snap! flat design.

For information on how to write Snapblocks code, visit https://snap-blocks.github.io/docs/Syntax.

See also

[edit]