Piet's HomePage
Klein, fein und noch im Aufbau
Hallo Besucher!
Deine IP: [216.73.216.174]
<sxh [brush][; options]> ... code/text ... </sxh>
The brush (language) that SyntaxHighlighter should use. Defaults to „text“ if none is provided. See SyntaxHighlighter Brushes page for a complete list of available brushes.
Semicolon separated options for SyntaxHighlighter, see SyntaxHighlighter Configuration.
The plugin handles the Block Title from SyntaxHighlighter 3 as an option, i.e. title: <title string>;.
Syntaxhighlighter default options can be overrided via the Config Manager :
(default true)(default 1)(default true)(default false)(default true)(default 4)<code> DokuWiki syntax (default false)<sxh php; first-line: 89; highlight: [106,107]; title: New title attribute in action>
/**
* Render xhtml output or metadata
*
* @param string $mode Renderer mode (supported modes: xhtml)
* @param Doku_Renderer $renderer The renderer
* @param array $data The data from the handler() function
* @return bool If rendering was successful.
*/
public function render($mode, Doku_Renderer &$renderer, $data) {
if($mode != 'xhtml') return false;
if (count($data) != 3) {
return true;
}
list($syntax, $attr, $content) = $data;
if ($syntax == 'sxh') {
$title = $this->procTitle($attr);
$highlight = $this->procHighlight($attr);
$renderer->doc .= '<pre class="brush: ' . strtolower($attr . $highlight) . '"' . $title . '>' . $renderer->_xmlEntities($content) . '</pre>';
} else {
$renderer->file($content);
}
return true;
}
</sxh>
Ergebnis:
/**
* Render xhtml output or metadata
*
* @param string $mode Renderer mode (supported modes: xhtml)
* @param Doku_Renderer $renderer The renderer
* @param array $data The data from the handler() function
* @return bool If rendering was successful.
*/
public function render($mode, Doku_Renderer &$renderer, $data) {
if($mode != 'xhtml') return false;
if (count($data) != 3) {
return true;
}
list($syntax, $attr, $content) = $data;
if ($syntax == 'sxh') {
$title = $this->procTitle($attr);
$highlight = $this->procHighlight($attr);
$renderer->doc .= '<pre class="brush: ' . strtolower($attr . $highlight) . '"' . $title . '>' . $renderer->_xmlEntities($content) . '</pre>';
} else {
$renderer->file($content);
}
return true;
}
Double click anywhere inside SyntaxHighlighter code area to highlight the text and then copy it using Ctrl/Cmd+C or mouse right click > Copy. Click outside the code area to restore highlighting.
Beispiel:
<sxh php; highlight: [11-15]>
/**
* [Custom event handler which performs action]
*
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_metaheader(Doku_Event &$event, $param) {
// Add SyntaxHighlighter theme.
$event->data['link'][] = array('rel' => 'stylesheet',
'type' => 'text/css',
'href' => DOKU_BASE . 'lib/plugins/syntaxhighlighter4/dist/'.$this->getConf('theme'),
);
// Register SyntaxHighlighter javascript.
$event->data["script"][] = array("type" => "text/javascript",
"src" => DOKU_BASE . "lib/plugins/syntaxhighlighter4/dist/syntaxhighlighter.js",
"_data" => ""
);
}
</sxh>
Ergebnis:
/**
* [Custom event handler which performs action]
*
* @param Doku_Event $event event object by reference
* @param mixed $param [the parameters passed as fifth argument to register_hook() when this
* handler was registered]
* @return void
*/
public function handle_metaheader(Doku_Event &$event, $param) {
// Add SyntaxHighlighter theme.
$event->data['link'][] = array('rel' => 'stylesheet',
'type' => 'text/css',
'href' => DOKU_BASE . 'lib/plugins/syntaxhighlighter4/dist/'.$this->getConf('theme'),
);
// Register SyntaxHighlighter javascript.
$event->data["script"][] = array("type" => "text/javascript",
"src" => DOKU_BASE . "lib/plugins/syntaxhighlighter4/dist/syntaxhighlighter.js",
"_data" => ""
);
}
[zurück]