-
Notifications
You must be signed in to change notification settings - Fork 4
/
syntax.php
50 lines (44 loc) · 1.4 KB
/
syntax.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Plugin for making callflow diagrams
*
* @note the js uses SVG/VXML from Raphaël.js @link:raphaeljs.com
*
* @author Bojidar Marinov <[email protected]>
*/
class syntax_plugin_callflow extends DokuWiki_Syntax_Plugin {
function getType(){return "protected";}
function getSort(){return 151;}
function connectTo($mode){$this->Lexer->addEntryPattern('<callflow>(?=.*?</callflow>)',$mode,'plugin_callflow');}
function postConnect() { $this->Lexer->addExitPattern('</callflow>','plugin_callflow'); }
/**
* Handle the match
*/
function handle($match, $state, $pos, Doku_Handler $handler)
{
switch ($state) {
case DOKU_LEXER_ENTER :
return array($state, array($state, $match));
case DOKU_LEXER_UNMATCHED : return array($state, $match);
case DOKU_LEXER_EXIT : return array($state, '');
}
return array();
}
/**
* Create output
*/
function render($mode, Doku_Renderer $renderer, $data)
{
// $data is what the function handle return'ed.
if($mode == 'xhtml'){
list($state,$match) = $data;
switch ($state) {
case DOKU_LEXER_ENTER : $renderer->doc .= "<pre callflow='true' style='border: none; box-shadow: none;background-color: #fff;'>"; break;
case DOKU_LEXER_UNMATCHED : $renderer->doc .= $renderer->_xmlEntities($match); break;
case DOKU_LEXER_EXIT : $renderer->doc .= "</pre>"; break;
}
return true;
}
return false;
}
}