Skip to content

Commit

Permalink
Merge pull request #17 from InternationalScratchWiki/high-contrast
Browse files Browse the repository at this point in the history
Update to support high contrast
  • Loading branch information
Kenny2github committed Jun 30, 2023
2 parents 9fede29 + 61effb3 commit acc8a9b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ A simple MediaWiki extension for rendering Scratch Blocks used on Scratch 3.0. S

Transforms `<scratchblocks>` tags inside wiki articles into `<pre class="blocks">` in the HTML, which are then rendered to scratch blocks using CSS and JS included in the page. Inline blocks are rendered with `<sb>` tags, and become `<code class="blocks">` tags.

Use `version` attribute to set the version. Valid values are `2`, `3`, and `hc-3` (for High Contrast colors).

- Maintained by apple502j.
- Contributed to by Kenny2github
- Original by tjvr and ErnieParke
Expand All @@ -24,3 +26,5 @@ $wgScratchBlocks4Langs = ['ja', 'zh_TW'];
Note that the TW is preceded by an underscore rather than a hyphen.

This variable is accessible through JavaScript via `mw.config.get("wgScratchBlocks4Lang")`.

Use `$wgScratchBlocks4BlockVersion` to specify the default version. Valid values are `2`, `3`, and `hc-3` (for High Contrast colors).
6 changes: 3 additions & 3 deletions lib/scratchblocks.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions lib/translations-all.js

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions run_scratchblocks4.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ mw.hook('wikipage.content').add(function run_scratchblocks() {
if (version == 2 || version[0] == '2') { // to handle '2.0'
version = 'scratch2';
} else {
version = 'scratch3';
version = (version === 'hc-3' || version === 'hc-3.0') ? 'scratch3-high-contrast' : 'scratch3';
scale = 0.675;
}
var langs = ['en'].concat(mw.config.get('wgScratchBlocks4Langs'));
scratchblocks.renderMatching('pre.blocks', { languages: langs, style: version, scale: scale });
scratchblocks.renderMatching('code.blocks', { languages: langs, style: version, inline: true, scale: scale });
scratchblocks.renderMatching('pre[class^=blocks-hc-3]', { languages: langs, style: 'scratch3-high-contrast', scale: 0.675 });
scratchblocks.renderMatching('code[class^=blocks-hc-3]', { languages: langs, style: 'scratch3-high-contrast', inline: true, scale: 0.675 });
scratchblocks.renderMatching('pre[class^=blocks-3]', { languages: langs, style: 'scratch3', scale: 0.675 });
scratchblocks.renderMatching('code[class^=blocks-3]', { languages: langs, style: 'scratch3', inline: true, scale: 0.675 });
scratchblocks.renderMatching('pre[class^=blocks-2]', { languages: langs, style: 'scratch2' });
scratchblocks.renderMatching('code[class^=blocks-2]', { languages: langs, style: 'scratch2', inline: true });
var query = '[class^=blocks-3] .scratchblocks svg';
if (version === 'scratch3') {
query = '.blocks .scratchblocks svg, ' + query;
}
});

0 comments on commit acc8a9b

Please sign in to comment.