* * And mark your text as:##anything|This is the Text## * if you want to mark it as * * * @author Marc Wäckerlin http://marc.waeckerlin.org * License: GPL */ class syntax_plugin_importanttext extends DokuWiki_Syntax_Plugin { function getType() { return 'substition'; } function getSort() { return 70; } function accepts($mode) { if(!count($this->allowedModes)) { global $PARSER_MODES; $this->allowedModes = array_merge( $PARSER_MODES['container'], $PARSER_MODES['baseonly'], $PARSER_MODES['formatting'], $PARSER_MODES['substition'], $PARSER_MODES['protected'], $PARSER_MODES['disabled'], $PARSER_MODES['paragraphs'] ); } return parent::accepts($mode); } function connectTo($mode) { $this->Lexer->addEntryPattern( '##[a-z]+\|(?=[^\n]*##)', $mode, 'plugin_importanttext' ); $this->Lexer->addEntryPattern( '##(?=[^\n]*##)', $mode, 'plugin_importanttext' ); } function postConnect() { $this->Lexer->addExitPattern( '##', 'plugin_importanttext' ); } function handle($match, $state, $pos, &$handler) { return array($match, $state); } function render($format, &$renderer, $data) { list($match, $state) = $data; switch($state) { case DOKU_LEXER_ENTER: { if(strlen($match) > 3) $class = htmlspecialchars(substr($match, 2, strlen($match) - 3)); else $class = 'important'; $renderer->doc .= ''; } return true; case DOKU_LEXER_EXIT: { for($i = 0; $i < strlen($match) - 4; ++$i) $renderer->doc .= $match[$i]; $renderer->doc .= ''; } return true; case DOKU_LEXER_MATCHED: return true; case DOKU_LEXER_UNMATCHED: { $renderer->doc .= htmlspecialchars($match); } return true; } return false; } } ?>