-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathsyntax.php
48 lines (37 loc) · 1.27 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
<?php
/**
* DokuWiki Plugin sagecell (Syntax Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
* @author Jason Grout <[email protected]>
*/
// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_PLUGIN.'syntax.php';
class syntax_plugin_sagecell extends DokuWiki_Syntax_Plugin {
public function getType() {
return 'protected';
}
public function getPType() {
return 'normal';
}
public function getSort() {
return 65;
}
public function connectTo($mode) {
$this->Lexer->addSpecialPattern('<sagecell>.*?</sagecell>', $mode, 'plugin_sagecell');
}
public function handle($match, $state, $pos, &$handler){
$data = array("code" => str_replace('</script>', '<\/script>', substr($match,10,-11)));
return $data;
}
public function render($mode, &$renderer, $data) {
if($mode != 'xhtml') return false;
$renderer->doc .= "<div class=\"sage\"><script type=\"text/x-sage\">".$data["code"]."</script></div>";
return true;
}
}
// vim:ts=4:sw=4:et: