Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagecell
Path: blob/master/contrib/dokuwiki/syntax.php
447 views
1
<?php
2
/**
3
* DokuWiki Plugin sagecell (Syntax Component)
4
*
5
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6
* @author Jason Grout <[email protected]>
7
*/
8
9
// must be run within Dokuwiki
10
if (!defined('DOKU_INC')) die();
11
12
if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
13
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
14
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
15
16
require_once DOKU_PLUGIN.'syntax.php';
17
18
class syntax_plugin_sagecell extends DokuWiki_Syntax_Plugin {
19
public function getType() {
20
return 'protected';
21
}
22
23
public function getPType() {
24
return 'normal';
25
}
26
27
public function getSort() {
28
return 65;
29
}
30
31
32
public function connectTo($mode) {
33
$this->Lexer->addSpecialPattern('<sagecell>.*?</sagecell>', $mode, 'plugin_sagecell');
34
}
35
36
public function handle($match, $state, $pos, &$handler){
37
$data = array("code" => str_replace('</script>', '<\/script>', substr($match,10,-11)));
38
return $data;
39
}
40
41
public function render($mode, &$renderer, $data) {
42
if($mode != 'xhtml') return false;
43
$renderer->doc .= "<div class=\"sage\"><script type=\"text/x-sage\">".$data["code"]."</script></div>";
44
return true;
45
}
46
}
47
48
// vim:ts=4:sw=4:et:
49
50