Lexer->addSpecialPattern($pattern, $mode, PluginUtility::getModeFromTag($this->getPluginComponent())); } function handle($match, $state, $pos, Doku_Handler $handler) { switch ($state) { case DOKU_LEXER_SPECIAL : $attributes = [syntax_plugin_combo_heading::LEVEL => strlen(trim($match))]; $callStack = CallStack::createFromHandler($handler); // Determine the type $context = syntax_plugin_combo_heading::getContext($callStack); /** * The context is needed: * * to add the bootstrap class if it's a card title for instance * * and to delete {@link syntax_plugin_combo_heading::TYPE_OUTLINE} call * in the {@link action_plugin_combo_headingpostprocess} (The rendering is done via Dokuwiki, * see the exit processing for more info on the handling of outline headings) * */ return array( PluginUtility::STATE => $state, PluginUtility::ATTRIBUTES => $attributes, PluginUtility::CONTEXT => $context, PluginUtility::POSITION => $pos ); } return array(); } /** * 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) { /** * * The atx special call is transformed by the {@link action_plugin_combo_headingpostprocess} * into enter and exit call */ if ($format == 'xhtml') { /** @var Doku_Renderer_xhtml $renderer */ $state = $data[PluginUtility::STATE]; switch ($state) { case DOKU_LEXER_ENTER: $attributes = $data[PluginUtility::ATTRIBUTES]; $context = $data[PluginUtility::CONTEXT]; $tagAttributes = TagAttributes::createFromCallStackArray($attributes, syntax_plugin_combo_heading::TAG); $pos = $data[PluginUtility::POSITION]; syntax_plugin_combo_heading::renderOpeningTag($context, $tagAttributes, $renderer, $pos); return true; case DOKU_LEXER_EXIT: $attributes = $data[PluginUtility::ATTRIBUTES]; $tagAttributes = TagAttributes::createFromCallStackArray($attributes); $level = $tagAttributes->getValue(syntax_plugin_combo_heading::LEVEL); $renderer->doc .= "" . DOKU_LF; return true; } } else if ($format == renderer_plugin_combo_analytics::RENDERER_FORMAT) { /** * @var renderer_plugin_combo_analytics $renderer */ syntax_plugin_combo_heading::processMetadataAnalytics($data, $renderer); } else if ($format == "metadata") { /** * @var Doku_Renderer_metadata $renderer */ syntax_plugin_combo_heading::processHeadingMetadata($data, $renderer); } return false; } }