Extension: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 | GitHub: Note: |
|
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]- 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.
Done – Navigate to Special:Version on 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:
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/writing-snapblocks.
See also
[edit]| This extension is included in the following wiki farms/hosts and/or packages: This is not an authoritative list. Some wiki farms/hosts and/or packages may contain this extension even if they are not listed here. Always check with your wiki farms/hosts or bundle to confirm. |
