This repository has been archived on 2025-05-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
mw-ScratchBlocks2/ScratchblockHooks.php

29 lines
914 B
PHP
Raw Permalink Normal View History

2016-05-02 17:00:58 -04:00
<?php
class ScratchblockHook {
// Ouput HTML for <scratchblocks> tag
public static function sbParserInit (Parser $parser) {
// Register <scratchblocks> and <sb> tag
$parser->setHook('scratchblocks', array( "ScratchblockHook", 'sbRenderTag') );
$parser->setHook('sb', array( "ScratchblockHook", 'sbRenderInlineTag') );
//throw new Exception(var_dump($parser));
return true;
}
public static function sbSetup() {
global $wgOut;
$wgOut->addModules('ext.scratchBlocks');
}
// Output HTML for <scratchblocks> tag
2016-05-02 17:00:58 -04:00
public static function sbRenderTag ($input, array $args, Parser $parser, PPFrame $frame) {
return '<pre class="blocks">' . htmlspecialchars($input) . '</pre>';
}
// Output HTML for inline <sb> tag
public static function sbRenderInlineTag ($input, array $args, Parser $parser, PPFrame $frame) {
return '<code class="blocks">' . htmlspecialchars($input) . '</code>';
}
}
?>