Views

Code Syntax Highlighting Extension Test

The Wiki of Unify contains information on clients and devices, communications systems and unified communications. - Unify GmbH & Co. KG is a Trademark Licensee of Siemens AG.

Revision as of 12:21, 11 August 2006 by Stefan.muenz (talk | contribs)
Jump to: navigation, search

HTML code example

[html] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> <title>Test</title> </head> <body>

  • <a href="#">eins</a>
  • <a href="#">zwei</a>
  • <a href="#">drei</a>

</body> </html>


CSS code example

[css] ul, li {

   margin:0;
   padding:0;

} li {

   list-style-type:none;
   display:inline;
   width:240px;
   background-color:#FFFFCC;
   border-top:solid 1px black;
   border-left:solid 1px black;
   border-right:solid 1px black;

} .last {

   border-bottom:solid 1px black;

} li a {

   width:100%;
   height:100%;
   color:black;
   text-decoration:none;

} a:hover, a:active {

   background-color:#FFFFFF;

}

JavaScript code example

[javascript] function toggle(id, save) {

  ul = "ul_" + id;
  img = "img_" + id;
  ul_element = document.getElementById(ul);
  img_element = document.getElementById(img);
  if(ul_element) {
      if(ul_element.className == 'closed') {
         ul_element.className = "opened";
         img_element.src = "opened.gif";
      } 
      else {
         ul_element.className = "closed";
         img_element.src = "closed.gif";
      }
  }
  if(save == true) save_nav();

}

Java code example

[java] public boolean mouseDown (Event evt, int x, int y)

 {
   if(evt.target == cbutton){
     	r = g = b = 0;

rb = gb = bb = 255; trf_offset = tgf_offset = tbf_offset = fc_h_offset; trb_offset = tgb_offset = tbb_offset = (bc_h_offset + 255) - t_width;

   }    
   else{
     if ((x >= fc_h_offset && x <= fc_h_offset + fc_width) &&

(y >= rfc_v_offset && y <= rfc_v_offset + height)) { r = x - fc_h_offset; trf_offset = x; }

     if ((x >= fc_h_offset && x <= fc_h_offset + fc_width) &&

(y >= gfc_v_offset && y <= gfc_v_offset + height)) { g = x - fc_h_offset; tgf_offset = x; }

     if ((x >= fc_h_offset && x <= fc_h_offset + fc_width) &&

(y >= bfc_v_offset && y <= bfc_v_offset + height)) { b = x - fc_h_offset; tbf_offset = x; }

     if ((x >= bc_h_offset && x <= bc_h_offset + bc_width) &&

(y >= rbc_v_offset && y <= rbc_v_offset + height)) { rb = x - bc_h_offset; trb_offset = x; }

     if ((x >= bc_h_offset && x <= bc_h_offset + bc_width) &&

(y >= gbc_v_offset && y <= gbc_v_offset + height)) { gb = x - bc_h_offset; tgb_offset = x; }

     if ((x >= bc_h_offset && x <= bc_h_offset + bc_width) &&

(y >= bbc_v_offset && y <= bbc_v_offset + height)) { bb = x - bc_h_offset; tbb_offset = x; }

   }
   repaint ();
   return (true);
 }

PHP code example

[php] /* Returns an array with all the scripts presents under the 'scripts' dir. */ function get_script_list() {

       $array = array();
       $dir = opendir("scripts");
       if (!$dir) {
           return $array;
       }
       while($entry = readdir($dir)) {
           if ($entry == "." || $entry == "..") continue;
               $array[] = $entry;
       }
       closedir($dir);
       return $array;

}

Supported languages

  • ActionScript (Flash)
  • Ada
  • Apache (configuration and htaccess files)
  • Assembler
  • Bash (Shellscripts)
  • C/C++
  • CSS
  • CSharp
  • DOS (batch files)
  • Delphi
  • Eiffel
  • HTML/XHTML
  • INI files
  • Java/Java5
  • JavaScript
  • Lisp
  • MatLab
  • Oracle8
  • PHP
  • Pascal
  • Perl
  • Pseudocode
  • Python
  • QBasic
  • Ruby
  • SQL
  • Scheme
  • Smarty
  • VisualBasic
  • XML

Hints to the syntax

Code syntax highlighting will generate preformatted areas. In order to do so you start with entering <code>[''language''] in an own line, where language is one of the allowed keywords (see box below). Then you enter or paste the code fragment. At the end of the section you enter </code> in an own line. That's all!

Note that you do not need to start each code line with a blank, as it is required in ordinary preformatted areas using MediaWiki syntax.

Allowed language keywords

 actionscript, ada, apache, asm, c, cpp, eiffel, ini, html, xhtml, 
 java, java5, css, js, javascript, vbnet, csharp, pascal, xml, php, 
 delphi, bash, perl, lisp, matlab, mpasm, objc, vb, smarty, vhdl, 
 ruby, sql, python, pseudocode, qbasic, scheme, oracle8, dos

Options

  • <code>[language]... // line_no default=Y, start_at default=1
  • <code>[language,N]... // no line numbers
  • <code>[language,5]... // start at line 5 (with line numbers
  • <code>[language,Y,5]... // deprecated - same as above
  • <code>[language,1,(3-5,7)]... // mark lines 3,4,5 and 7

language is always required!