getConfig(); $htmlTag = self::HTML_TAG; if (!$config->isBrandingColorInheritanceEnabled()) { return "<$htmlTag>"; } try { $primaryColor = $config->getPrimaryColor(); } catch (ExceptionNotFound $e) { return "<$htmlTag>"; } $tagAttributes = TagAttributes::createEmpty($tag); try { $colorRgb = ColorSystem::toBackgroundColor($primaryColor); $tagAttributes->addComponentAttributeValue(ColorRgb::BACKGROUND_COLOR, $colorRgb ->toRgbHex()); } catch (ExceptionCompile $e) { LogUtility::msg("Error on highlight color calculation", self::CANONICAL, $e); } return $tagAttributes->toHtmlEnterTag($htmlTag); } public function getSort(): int { /** * It's 49 (on less than the original of 100) named monospace * {@link \dokuwiki\Parsing\ParserMode\Formatting} */ return 49; } public function getType(): string { return 'formatting'; } /** * * How Dokuwiki will add P element * * * 'normal' - The plugin can be used inside paragraphs (inline) * * 'block' - Open paragraphs need to be closed before plugin output - block should not be inside paragraphs * * 'stack' - Special case. Plugin wraps other paragraphs. - Stacks can contain paragraphs * * @see DokuWiki_Syntax_Plugin::getPType() * * This is the equivalent of inline or block for css */ public function getPType(): string { return 'normal'; } /** * @return array * Allow which kind of plugin inside * * No one of array('baseonly','container', 'formatting', 'substition', 'protected', 'disabled', 'paragraphs') * because we manage self the content and we call self the parser * * Return an array of one or more of the mode types {@link $PARSER_MODES} in Parser.php */ function getAllowedTypes(): array { return array('formatting', 'substition', 'protected', 'disabled'); } public function connectTo($mode) { $enabled = SiteConfig::getConfValue(self::CONF_HIGHLIGHT_WIKI_ENABLE, self::CONF_DEFAULT_HIGHLIGHT_WIKI_ENABLE_VALUE); if ($enabled) { $this->Lexer->addEntryPattern(self::ENTRY_PATTERN, $mode, PluginUtility::getModeFromTag($this->getPluginComponent())); } } public function postConnect() { $this->Lexer->addExitPattern(self::EXIT_PATTERN, PluginUtility::getModeFromTag($this->getPluginComponent())); } /** * Handle the syntax * * At the end of the parser, the `section_open` and `section_close` calls * are created in {@link action_plugin_combo_instructionspostprocessing} * and the text inside for the toc is captured * * @param string $match * @param int $state * @param int $pos * @param Doku_Handler $handler * @return array */ public function handle($match, $state, $pos, Doku_Handler $handler): array { switch ($state) { case DOKU_LEXER_EXIT: case DOKU_LEXER_ENTER: return array( PluginUtility::STATE => $state ); case DOKU_LEXER_UNMATCHED : return PluginUtility::handleAndReturnUnmatchedData(self::TAG, $match, $handler); } return array(); } public function render($format, $renderer, $data): bool { switch ($format) { case "xhtml": { /** * @var Doku_Renderer_xhtml $renderer */ $state = $data[PluginUtility::STATE]; switch ($state) { case DOKU_LEXER_ENTER: $renderer->doc .= self::getOpenTagHighlight(self::TAG); return true; case DOKU_LEXER_UNMATCHED: $renderer->doc .= PluginUtility::renderUnmatched($data); return true; case DOKU_LEXER_EXIT: $htmlTag = self::HTML_TAG; $renderer->doc .= ""; return true; } break; } case "metadata": /** * @var Doku_Renderer_metadata $renderer */ $state = $data[PluginUtility::STATE]; switch ($state) { case DOKU_LEXER_UNMATCHED: $renderer->doc .= PluginUtility::renderUnmatched($data); } break; } return false; } }