1a345322fSVincent.Tscherter<?php 2a345322fSVincent.Tscherter/** 3a345322fSVincent.Tscherter * Dokuwiki Plugin EBNF: Displays Syntax Diagrams 4a345322fSVincent.Tscherter * 5a345322fSVincent.Tscherter * Syntax: <ebnf> ebnf syntax </ebnf> 6a345322fSVincent.Tscherter * 7a345322fSVincent.Tscherter * @license GPL3 8a345322fSVincent.Tscherter * @author Vincent Tscherter <vinent.tscherter@karmin.ch> 9a345322fSVincent.Tscherter * @version 0.1 10a345322fSVincent.Tscherter */ 11a345322fSVincent.Tscherter 12*77a47d83SVincent Tscherteruse dokuwiki\Extension\SyntaxPlugin; 13a345322fSVincent.Tscherter 14a345322fSVincent.Tscherterclass syntax_plugin_ebnf extends DokuWiki_Syntax_Plugin { 15a345322fSVincent.Tscherter 16a345322fSVincent.Tscherter function getType(){ 17a345322fSVincent.Tscherter return 'substition'; 18a345322fSVincent.Tscherter } 19a345322fSVincent.Tscherter 20a345322fSVincent.Tscherter function getSort(){ 21a345322fSVincent.Tscherter return 999; 22a345322fSVincent.Tscherter } 23a345322fSVincent.Tscherter 24a345322fSVincent.Tscherter function connectTo($mode) { 25a345322fSVincent.Tscherter $this->Lexer->addSpecialPattern('<ebnf>.*?</ebnf>',$mode,'plugin_ebnf'); 26a345322fSVincent.Tscherter } 27a345322fSVincent.Tscherter 285c02957eSAndreas Gohr function handle($match, $state, $pos, Doku_Handler $handler){ 29a345322fSVincent.Tscherter switch ($state) { 30a345322fSVincent.Tscherter case DOKU_LEXER_ENTER : 31a345322fSVincent.Tscherter break; 32a345322fSVincent.Tscherter case DOKU_LEXER_MATCHED : 33a345322fSVincent.Tscherter break; 34a345322fSVincent.Tscherter case DOKU_LEXER_UNMATCHED : 35a345322fSVincent.Tscherter break; 36a345322fSVincent.Tscherter case DOKU_LEXER_EXIT : 37a345322fSVincent.Tscherter break; 38a345322fSVincent.Tscherter case DOKU_LEXER_SPECIAL : 39a345322fSVincent.Tscherter break; 40a345322fSVincent.Tscherter } 41a345322fSVincent.Tscherter return array($match); 42a345322fSVincent.Tscherter } 43a345322fSVincent.Tscherter 445c02957eSAndreas Gohr function render($mode, Doku_Renderer $renderer, $data) { 45a345322fSVincent.Tscherter if($mode == 'xhtml'){ 46a345322fSVincent.Tscherter try { 47a345322fSVincent.Tscherter $text = substr($data[0], 6, strlen($data[0])-13); 48a345322fSVincent.Tscherter $text = preg_replace( "/[<>]+/", "", $text); 49a345322fSVincent.Tscherter $text = preg_replace( "/[\\n\\r\\t ]+/", " ", $text); 50a345322fSVincent.Tscherter $text = urlencode($text); 51a345322fSVincent.Tscherter $renderer->doc .= "<img src='".DOKU_URL."lib/plugins/ebnf/ebnf.php?syntax=$text' alt='$text'/>"; // ptype = 'normal' 52a345322fSVincent.Tscherter } catch (Exception $e) { 53a345322fSVincent.Tscherter $renderer->doc .= "<pre>".htmlentities($text)."\n".$e."</pre>"; 54a345322fSVincent.Tscherter } 55a345322fSVincent.Tscherter return true; 56a345322fSVincent.Tscherter } 57a345322fSVincent.Tscherter return false; 58a345322fSVincent.Tscherter } 59a345322fSVincent.Tscherter} 60a345322fSVincent.Tscherter?>