Extension:Snapblocks
- English
- 日本語
Release status: stable |
|
|---|---|
| Implementation | Tag |
| Description | Create Snap! blocks from text. |
| Author(s) |
|
| Latest version | 2.2.0 (2025年09月15日) |
| Compatibility policy | Master maintains backward compatibility. |
| MediaWiki | >= 1.40.0 |
| Database changes | No |
|
|
<snapblocks>, <scratchblocks>, <sb> |
|
| Licence | MIT License |
| Download | README |
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.
Installation
[edit ]- Download and place the file(s) in a directory called
Snapblocksin yourextensions/folder. - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'Snapblocks' );
- Configure languages if needed.
- Yes Done – Navigate to
Special:Versionon your wiki to verify that the extension is successfully installed.
Configuration
[edit ]By default, only English Snap! blocks are rendered. Add more languages like so:
$wgSnapBlocksLangs = ['ja', 'zh_TW'];
TW part above 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>...</snapblocks>to create a block level element displaying Snap code. - Use
<scratchblocks>...</scratchblocks>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>...</sb>tags.
<snapblocks> repeat (5) { move (10) steps } say [Done!] </snapblocks>
You can map over a list in Snap! with a <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/writing-snapblocks.