* @author Danny Lin * @author Satoshi Sahara */ class syntax_plugin_commentsyntax_htmlcomment extends DokuWiki_Syntax_Plugin { /** syntax type */ public function getType() { return 'substition'; } /** sort number used to determine priority of this mode */ public function getSort() { return 325; } /** * Connect lookup pattern to lexer */ protected $mode, $pattern; public function preConnect() { // syntax mode, drop 'syntax_' from class name $this->mode = substr(__CLASS__, 7); // syntax pattern $this->pattern = [ 5 => '<\!--.*?-->', ]; } public function connectTo($mode) { $this->Lexer->addSpecialPattern($this->pattern[5], $mode, $this->mode); } /** * Handle the match */ public function handle($match, $state, $pos, Doku_Handler $handler) { if ($state == DOKU_LEXER_SPECIAL) { // strip from end return array($state, substr($match, 4, -3)); } return false; } /** * Create output */ public function render($format, Doku_Renderer $renderer, $data) { if ($format == 'xhtml') { list($state, $comment) = $data; if ($state == DOKU_LEXER_SPECIAL) { $renderer->doc .= ''; } return true; } return true; } }