Lexer->addSpecialPattern($pattern, $mode, PluginUtility::getModeFromTag($this->getPluginComponent())); } function handle($match, $state, $pos, Doku_Handler $handler): array { if ($state == DOKU_LEXER_SPECIAL) { $attributes = [HeadingTag::LEVEL => strlen(trim($match))]; $callStack = CallStack::createFromHandler($handler); // Determine the type $context = HeadingTag::getContext($callStack); /** * The context is needed: * * to add the bootstrap class if it's a card title for instance * * and to delete {@link HeadingTag::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): bool { /** * * 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]; $context = $data[PluginUtility::CONTEXT]; switch ($state) { case DOKU_LEXER_ENTER: $attributes = $data[PluginUtility::ATTRIBUTES]; $tagAttributes = TagAttributes::createFromCallStackArray($attributes, HeadingTag::HEADING_TAG); $pos = $data[PluginUtility::POSITION]; HeadingTag::processRenderEnterXhtml($context, $tagAttributes, $renderer, $pos); return true; case DOKU_LEXER_EXIT: $attributes = $data[PluginUtility::ATTRIBUTES]; $tagAttributes = TagAttributes::createFromCallStackArray($attributes); $renderer->doc .= HeadingTag::renderClosingTag($tagAttributes, $context); return true; } } else if ($format == renderer_plugin_combo_analytics::RENDERER_FORMAT) { /** * @var renderer_plugin_combo_analytics $renderer */ HeadingTag::processMetadataAnalytics($data, $renderer); } else if ($format == "metadata") { /** * @var Doku_Renderer_metadata $renderer */ HeadingTag::processHeadingEnterMetadata($data, $renderer); } return false; } }