Skip to content

Instantly share code, notes, and snippets.

@joelittlejohn
Created November 4, 2019 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelittlejohn/559469ad85a562e8586144509c6d5d15 to your computer and use it in GitHub Desktop.
Save joelittlejohn/559469ad85a562e8586144509c6d5d15 to your computer and use it in GitHub Desktop.
<?php
$wgExtensionCredits['parserhook'][] = array(
'name' => 'WebServiceSequenceDiagram',
'version' => '1.0',
'author' => 'Eddie Olsson',
'url' => 'http://www.mediawiki.org/wiki/Extension:WebSequenceDiagram',
'description' => 'Render inline sequence diagrams using websequencediagrams.com'
);
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
$wgHooks['ParserFirstCallInit'][] = 'webSequenceDiagramSetup';
} else { // Otherwise do things the old fashioned way
$wgExtensionFunctions[] = 'webSequenceDiagramSetup';
}
function webSequenceDiagramSetup() {
global $wgParser;
$wgParser->setHook( 'sequencediagram', 'webSequenceDiagramRender' );
return true;
}
function webSequenceDiagramRender( $input, $args, $parser) {
if( isset( $args['style'] ) )
$style= $args['style'];
else
$style = 'default';
$caption = '';
if( isset( $args['caption'] ) )
$caption = '<div class="thumbcaption">' . $args['caption'] . '</div>';
return "\n" .
'<div class="thum tnone"><div class="thumbinner">' .
'<div class=wsd wsd_style="' . $style . '"><pre>\n' .
$input . "\n" .
'</pre></div>' . $caption . '</div><script type="text/javascript" src="//www.websequencediagrams.com/service.js"></script></div>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment