Lexer->addSpecialPattern($pattern, $mode, PluginUtility::getModeFromTag($this->getPluginComponent())); } } /** * * @param string $match The text matched by the patterns * @param int $state The lexer state for the match * @param int $pos The character position of the matched text * @param Doku_Handler $handler The Doku_Handler object * @return array Return an array with all data you want to use in render */ public function handle($match, $state, $pos, Doku_Handler $handler) { return array($match); } /** * Render the output * @param string $format * @param Doku_Renderer $renderer * @param array $data - what the function handle() return'ed * @return boolean - rendered correctly? (however, returned value is not used at the moment) * @see DokuWiki_Syntax_Plugin::render() * * */ function render($format, Doku_Renderer $renderer, $data) { list($content) = $data; switch ($format) { case 'xhtml': case 'odt': /** @var Doku_Renderer_xhtml $renderer */ $renderer->doc .= $renderer->_xmlEntities($content) . DOKU_LF; /** * CSS */ $snippetManager = PluginUtility::getSnippetManager(); $snippetManager->attachCssInternalStyleSheetForSlot(self::TAG); /** * Javascript config */ $headHtmlElement = <<",""]], displayMath: [ ["",""] ], processEscapes: true, scale:120 }, "HTML-CSS": { fonts: ["TeX"] } }); EOD; $snippetManager ->attachInternalJavascriptForSlot( self::TAG, $headHtmlElement ) ->addHtmlAttribute("type", "text/x-mathjax-config"); $snippetManager ->attachJavascriptLibraryForSlot( self::TAG, "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js" ) ->setDoesManipulateTheDomOnRun(false); break; case 'latexport': // Pass math expressions to latexport renderer $renderer->mathjax_content($content); break; default: $renderer->doc .= $renderer->$data; break; } return true; } static public function getTags() { return PluginUtility::getTags(get_called_class()); } public static function getComponentName() { return PluginUtility::getTagName(get_called_class()); } }