-
Notifications
You must be signed in to change notification settings - Fork 2
/
syntax.php
77 lines (67 loc) · 1.63 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* DokuWiki Plugin textrotate (Syntax Component)
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author lisps
* @author peterfromearth
*/
class syntax_plugin_textrotate extends DokuWiki_Syntax_Plugin {
public function getType(){ return 'formatting'; }
public function getAllowedTypes() { return array('formatting', 'substition', 'disabled'); }
public function getSort(){ return 66; }
/*
* Connect pattern to lexer
*/
function connectTo($mode) {
$this->Lexer->addEntryPattern(
'!!(?=.*!!)',
$mode,
'plugin_textrotate'
);
}
function postConnect() {
$this->Lexer->addExitPattern(
'!!',
'plugin_textrotate'
);
}
/*
* Handle the matches
*/
function handle($match, $state, $pos, Doku_Handler $handler){
switch ($state) {
case DOKU_LEXER_ENTER :
return [$state, ''];
case DOKU_LEXER_UNMATCHED :
return [$state, $match];
case DOKU_LEXER_EXIT :
return [$state, ''];
}
return [];
}
/*
* Create output
*/
function render($mode, Doku_Renderer $renderer, $data)
{
list($state, $opt) = $data;
if($mode != 'xhtml') return false;
switch ($state) {
case DOKU_LEXER_ENTER :
if($mode === 'xhtml') {
$renderer->doc .= "<span class='plugin_textrotate_rotated'>";
}
break;
case DOKU_LEXER_UNMATCHED :
$renderer->doc .= $renderer->_xmlEntities($opt);
break;
case DOKU_LEXER_EXIT :
if($mode === 'xhtml') {
$renderer->doc .= '</span>';
}
break;
}
return true;
}
}