syntax.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // must be run within Dokuwiki
  3. if(!defined('DOKU_INC')) die();
  4. /**
  5. * All DokuWiki plugins to extend the parser/rendering mechanism
  6. * need to inherit from this class
  7. */
  8. class syntax_plugin_subnumberlist extends DokuWiki_Syntax_Plugin {
  9. public function getType(){ return 'container'; }
  10. public function getAllowedTypes() { return array('container'); }
  11. public function getSort(){ return 158; }
  12. public function connectTo($mode) {
  13. $this->Lexer->addEntryPattern('<subnumberlist>(?=.*?</subnumberlist>)',$mode,'plugin_subnumberlist');
  14. }
  15. public function postConnect() {
  16. $this->Lexer->addExitPattern('</subnumberlist>','plugin_subnumberlist');
  17. }
  18. /**
  19. * Handle the match
  20. */
  21. public function handle($match, $state, $pos, Doku_Handler $handler){
  22. switch ($state) {
  23. case DOKU_LEXER_ENTER:
  24. return array($state, $match);
  25. case DOKU_LEXER_UNMATCHED :
  26. return array($state, $match);
  27. case DOKU_LEXER_EXIT :
  28. return array($state, '');
  29. }
  30. return false;
  31. }
  32. public function render($mode, Doku_Renderer $renderer, $indata) {
  33. if($mode == 'xhtml') {
  34. list($state, $match) = $indata;
  35. switch ($state) {
  36. case DOKU_LEXER_ENTER :
  37. $renderer->doc .= '<div class="subnumberlist">';
  38. break;
  39. case DOKU_LEXER_UNMATCHED :
  40. $renderer->doc .= $renderer->_xmlEntities($match);
  41. break;
  42. case DOKU_LEXER_EXIT :
  43. $renderer->doc .= '</div>';
  44. break;
  45. }
  46. return true;
  47. }
  48. return false;
  49. }
  50. }
  51. //Setup VIM: ex: et ts=4 enc=utf-8 :
  52. ?>