* @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @version htag syntax plugin, v0.9 * @since 23-Jul-2007 **/ class syntax_plugin_htag extends DokuWiki_Syntax_Plugin { function getInfo() { return array ( 'author' => 'Adam B. Ross', 'email' => 'grayside@gmail.com', 'date' => '2007-07-23', 'name' => 'Heading Level Tag', 'desc' => 'Adds outline-style markup (h1.~) syntax for headings.', 'url' => 'https://www.dokuwiki.org/plugin:htag' ); } // header specific function getType() { return 'baseonly'; } // headings shouldn't be parsed.. function accepts($mode) { return false; } function connectTo( $mode ) { $this->Lexer->addSpecialPattern( '^[hH][1-6]\.[ \t]*[^\n]+(?=\n)', $mode, 'plugin_htag' ); } // Doku_Parser_Mode 60 // header (numbered headers) 45 function getSort() { return 44; } function handle( $match, $state, $pos, Doku_Handler $handler) { { global $conf; preg_match( '/^h\d/i', $match, $htag ); $title = substr( $match, 3 ); $title = trim($title); $level = substr( $htag[0], 1, 1 ); if( $handler->getStatus('section') ) $handler->addCall('section_close',array(), $pos); if( $level <= $conf['maxseclevel'] ) { $handler->addCall('section_edit',array($handler->getStatus('section_edit_start'), $pos-1, $handler->getStatus('section_edit_level'), $handler->getStatus('section_edit_title')), $pos); $handler->setStatus('section_edit_start', $pos); $handler->setStatus('section_edit_level', $level); $handler->setStatus('section_edit_title', $title); } $handler->addCall('header',array($title,$level,$pos), $pos); $handler->addCall('section_open',array($level),$pos); $handler->setStatus('section', true); return true; } function render( $format, Doku_Renderer $renderer, $data) { { return true; } }