.... * * syntax: %your_class{...}% * * You may embed any syntax between the shorthand opening and closing tags * that you can embed in (for example) the DokuWiki **...** bold syntax, * except that you can't nest a span shorthand within a span shorthand. If * anyone knows how to allow nesting, please let me know. * * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Joe Lapp */ if(!defined('DOKU_INC')) die(); class syntax_plugin_shorthand_span extends DokuWiki_Syntax_Plugin { function getType() { return 'formatting'; } function getAllowedTypes() { return array('substition','protected','disabled','formatting'); } function getSort() { return 500; } // I'm not sure what's appropriate // override default accepts() method to allow nesting // - ie, to get the plugin accepts its own entry syntax function accepts($mode) { if ($mode == substr(get_class($this), 7)) return true; return parent::accepts($mode); } function connectTo($mode) { $this->Lexer->addEntryPattern('\%[a-zA-Z0-9_-]+\{(?=.*\x7D\x25)', $mode, 'plugin_shorthand_span'); } function postConnect() { $this->Lexer->addExitPattern('\}\%', 'plugin_shorthand_span'); } function handle($match, $state, $pos, Doku_Handler $handler) { switch($state) { case DOKU_LEXER_ENTER: return array($state, substr($match, 1, -1)); case DOKU_LEXER_UNMATCHED: return array($state, $match); case DOKU_LEXER_EXIT: return array($state, ''); } return array(); } function render($mode, Doku_Renderer $renderer, $data) { if($mode == 'xhtml') { list($state, $match) = $data; switch($state) { case DOKU_LEXER_ENTER: //toc is lost when we use $renderer->nest so we back it up here //$this->toc = $renderer->toc; $renderer->doc .= ''; break; case DOKU_LEXER_UNMATCHED: $renderer->doc .= htmlspecialchars($match); // if you want to render instructions placed inside the tag : // $renderer->doc .= $renderer->nest(p_get_instructions($match)); break; case DOKU_LEXER_EXIT: $renderer->doc .= ''; //toc restore //$renderer->toc = $this->toc; break; } return true; } return false; } } ?>