(?=.*?)',$mode,'plugin_note');
}
function postConnect() {
$this->Lexer->addExitPattern('','plugin_note');
}
function handle($match, $state, $pos, &$handler){
switch ($state) {
case DOKU_LEXER_ENTER :
$note = strtolower(trim(substr($match,5,-1)));
foreach( $this->notes as $class => $names ) {
if (in_array($note, $names))
return array($state, $class);
}
return array($state, $this->default);
case DOKU_LEXER_UNMATCHED :
return array($state, $match);
default:
return array($state);
}
}
function render($mode, &$renderer, $indata) {
if($mode == 'xhtml'){
list($state, $data) = $indata;
switch ($state) {
case DOKU_LEXER_ENTER :
$renderer->doc .= '';
break;
case DOKU_LEXER_UNMATCHED :
$renderer->doc .= $renderer->_xmlEntities($data);
break;
case DOKU_LEXER_EXIT :
$renderer->doc .= "\n
";
break;
}
return true;
} elseif ($mode == 'odt'){
list($state, $data) = $indata;
switch ($state) {
case DOKU_LEXER_ENTER :
$type = substr($data, 4);
if ($type == "classic") {
$type = "note"; // the icon for classic notes is named note.png
}
$colors = array("note"=>"#eeffff", "warning"=>"#ffdddd", "important"=>"#ffffcc", "tip"=>"#ddffdd");
$renderer->autostyles["pluginnote"] = '
';
$renderer->autostyles["pluginnote.A"] = '
';
$renderer->autostyles["pluginnote.B"] = '
';
$renderer->autostyles["pluginnote".$type.".A1"] = '
';
$renderer->autostyles["pluginnote".$type.".B1"] = '
';
// Content
$renderer->p_close();
$renderer->doc .= '';
$renderer->doc .= '';
$renderer->doc .= '';
$renderer->doc .= '';
$renderer->doc .= '';
// Don't use p_open, as it's not the same style-name
$renderer->doc .= '';
$src = DOKU_PLUGIN."note/images/".$type.".png";
$renderer->_odtAddImage($src);
$renderer->doc .= '';
$renderer->doc .= '';
$renderer->doc .= '';
$renderer->p_open();
break;
case DOKU_LEXER_UNMATCHED :
$renderer->cdata($data);
break;
case DOKU_LEXER_EXIT :
$renderer->p_close();
$renderer->doc .= '';
$renderer->doc .= '';
$renderer->doc .= '';
$renderer->p_open();
break;
}
return true;
}
// unsupported $mode
return false;
}
}
//Setup VIM: ex: et ts=4 enc=utf-8 :
?>