The issue has been discussed in
- https://stackoverflow.com/questions/56520743/integrating-openjscad-into-mediawiki/56520809#56520809
- https://openjscad.nodebb.com/topic/98/displaying-jscad-designs-in-media-wiki-or-plain-html-for-a-start
The feasibility has been proven in http://wiki.bitplan.com/index.php/ParametricLampShade and http://wiki.bitplan.com/index.php/Template:Jscad but these prototypes use the html extension.
The idea is to have a separate extension. A first cut in "old style extension" php has been drafted as:
<?php /** * Check if we are being called directly */ if ( !defined( 'MEDIAWIKI' ) ) { die( 'This file is an extension to MediaWiki and thus not a valid entry point.' ); } /** * Register this extension on Special:Version */ $wgExtensionCredits['parserhook'][] = array( 'name' => 'OpenJsCad', 'description' => 'Allows embedding of OpenJsCad designs', 'author' => array( 'Wolfgang Fahl' ), 'url' => 'http://wiki.bitplan.com/OpenJsCadExtension', 'version' => '0.0.1' ); $wgHooks['ParserFirstCallInit'][] = 'wfRegisterOpenJsCad'; /** * Sets the tag <jscad></jscad> that this extension looks for and the function by which it * operates */ function wfRegisterOpenJsCad( Parser $parser ) { $parser->setHook( 'jscad', 'renderOpenJsCad' ); return true; } /** * Renders a JSCAD design * <jscad title='MyDesign'>function main() { return cube ...}</jscad> * * @tagcontent code * The code is javascript in JSCAD format * * @param title * The title is is the title e.g. 'previous' * * @return string * The necessary html code to render the design */ function renderOpenJsCad($input, array $args, Parser $parser, PPFrame $frame) { if (isset($args["nocache"])) { $parser->disableCache(); } // in case WikiMarkup / Templates have been used to specify page .. $rawCode=$input; $input="<source lang='javascript'>".$input."</source>"; $code = $parser->recursiveTagParse( $input, $frame ); $title= "OpenJSCAD design"; $target="_self"; // title part if (isset($args["title"])) { $title=$args["title"]; $title=$parser->recursiveTagParse( $title, $frame ); } $result="<script src='/extensions/OpenJsCad/lightgl.js'></script>\n"; $result.="<script src='/extensions/OpenJsCad/csg.js'></script>\n"; $result.="<script src='/extensions/OpenJsCad/openjscad.js'></script>\n"; $result.=$code; $result.="<textarea id='code'>".$rawCode."</textarea>\n"; // make sure our result is not parsed return array($result,"markerType"=>'nowiki'); }
So that a <jscad> tag would be supported.