/** * Handle the match */ function handle($match, $state, $pos, Doku_Handler $handler) { global $conf; switch ($state) { case DOKU_LEXER_ENTER: $data = strtolower(trim(substr($match, strpos($match, ' '), -1))); return array($state, $data); case DOKU_LEXER_UNMATCHED: // check if $match is a == header == $headerMatch = preg_grep('/([ \\t]*={2,}[^\\n]+={2,}[ \\t]*(?=))/msSi', array($match)); if (empty($headerMatch)) { $handler->_addCall('cdata', array($match), $pos); } else { // if it's a == header ==, use the core header() renderer // (copied from core header() in inc/parser/handler.php) $title = trim($match); $level = 7 - strspn($title, '='); if ($level < 1) { $level = 1; } $title = trim($title, '='); $title = trim($title); $handler->_addCall('header', array($title, $level, $pos), $pos); // close the section edit the header could open if ($title && $level <= $conf['maxseclevel']) { $handler->addPluginCall('wrap_closesection', array(), DOKU_LEXER_SPECIAL, $pos, ''); } } return false; case DOKU_LEXER_EXIT: return array($state, ''); } return false; }
/** * Handle the match */ function handle($match, $state, $pos, Doku_Handler $handler){ global $conf; switch ($state) { case DOKU_LEXER_ENTER: case DOKU_LEXER_SPECIAL: $data = strtolower(trim(substr($match,strpos($match,' '),-1)," \t\n/")); return array($state, $data); case DOKU_LEXER_UNMATCHED: $handler->_addCall('cdata', array($match), $pos); break; case DOKU_LEXER_MATCHED: // we have a == header ==, use the core header() renderer // (copied from core header() in inc/parser/handler.php) $title = trim($match); $level = 7 - strspn($title,'='); if($level < 1) $level = 1; $title = trim($title,'='); $title = trim($title); $handler->_addCall('header',array($title,$level,$pos), $pos); // close the section edit the header could open if ($title && $level <= $conf['maxseclevel']) { $handler->addPluginCall('wrap_closesection', array(), DOKU_LEXER_SPECIAL, $pos, ''); } break; case DOKU_LEXER_EXIT: return array($state, ''); } return false; }