====== Code ====== ===== Syntax-Hervorhebung ===== DokuWiki kennt Syntax highlighting für Quellcode, um dessen Lesbarkeit zu erhöhen. Dafür wird GeSHi „Generic Syntax Highlighter“ benutzt. Somit wird jede Programmiersprache unterstützt, die GeSHi kennt. Es wird der Bezeichner code benutzt, und man muss nur den Namen der gewünschten Sprache angeben: Quelltext **Herunterladbarer Quelltext**\\ Quelltext Es werden folgende Sprachen unterstützt: actionscript, actionscript-french, ada, apache, applescript, asm, asp, bash, caddcl, cadlisp, c, c_mac, cpp, csharp, css, delphi, diff, d, div, dos, eiffel, freebasic, gml, html4strict, ini, inno, java, javascript, lisp, lua, matlab, mpasm, nsis, objc, ocaml, ocaml-brief, oobas, oracle8, pascal, perl, php-brief, php, python, qbasic, scheme, sdlbasic, smarty, sql, ruby, vb, vbnet, vhdl, visualfoxpro, xml ===== Beispiele ===== **vhdl** Quelltext process (clk, rst) begin if rst = ‘1’ then reg <= ‘0’; elsif clk = ‘1’ and clk’rising then reg <= reg_in; end if; end process; **vhdl zum herunterladen** Quelltext process (clk, rst) begin if rst = ‘1’ then reg <= ‘0’; elsif clk = ‘1’ and clk’rising then reg <= reg_in; end if; end process; **java** Quelltext /** * The HelloWorldApp class implements an application that * simply displays "Hello World!" to the standard output. */ class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); //Display the string. } } **html** Quelltext Hello World Demonstration Document

Hello, World!

This is a minimal "hello world" HTML document. It demonstrates the basic structure of an HTML file and anchors.

For more information, see the HTML Station at: http://www.december.com/html/


© John December (john@december.com) / 2001-04-06
===== Another Sample ===== public function render($mode, &$renderer, $data) { if($mode != 'xhtml') return false; if (count($data) == 3) { list($syntax, $attr, $content) = $data; if ($syntax == 'sxh') { // Check if there's a title in the attribute string. It can't be passed along as a normal parameter to SyntaxHighlighter. if (preg_match("/title:/i", $attr)) { // Extract title(s) from attribute string. $attr_array = explode(";",$attr); $title_array = preg_grep("/title:/i", $attr_array); // Extract everything BUT title(s) from attribute string. $not_title_array = preg_grep("/title:/i", $attr_array, PREG_GREP_INVERT); $attr = implode(";",$not_title_array); // If there are several titles, use the last one. $title = array_pop($title_array); $title = preg_replace("/.*title:\s{0,}(.*)/i","$1",$title); // Add title as an attribute to the
 tag.
                    $renderer->doc .= "
".$renderer->_xmlEntities($content)."
"; } else { // No title detected, pass all attributes as parameters to SyntaxHighlighter. $renderer->doc .= "
".$renderer->_xmlEntities($content)."
"; } } else { $renderer->file($content); } } return true; }