PerfSONAR Wiki Syntax Highlighting

From GEANT2-JRA1 Wiki

Contents

Usage

  <code>[java,N,10]
    public class X { 
      int i; 
    }
 </code>
  
  

Where [language,line_no_on (Y/N),line_no_start].

  • language - programming language/script
  • line_no_on - line numbering - Y-yes, N-no
  • line_no_start - initial line number

The default for line_no_on is Y, and line_no_start is 1, so we can just write a simple

Examples

Java

  • Put code inside <code>[java,N] ... </code>
public class abc {
  int a;
  public geta() { return a; }
}
  • with line numbering (from 20)
  1. public class abc {
  2. int a;
  3. public geta() { return a; }
  4. }

XML

  • Put code inside <code>[xml,N] ... </code>
<nmwg:message type="LSDeregisterRequest"
                   id="msg1"
                   xmlns:nmwg="http://ggf.org/ns/nmwg/base/2.0/">
    <nmwg:metadata id="key_to_remove">
      <nmwg:key>
          <nmwg:parameters id="keys">
            <nmwg:parameter name="lsKey">http://reed.man.poznan.pl:8080/axis/services/MA</nmwg:parameter>
          </nmwg:parameters>
      </nmwg:key>
    </nmwg:metadata>
    <nmwg:data/>
</nmwg:message>

Python

  • Put code inside <code>[python,N] ... </code>
def quicksort(list, start, end):
    if start < end:                            # If there are two or more elements...
        split = partition(list, start, end)    # ... partition the sublist...
        quicksort(list, start, split-1)        # ... and sort both halves.
        quicksort(list, split+1, end)
    else:
        return

Perl

  • Put code inside <code>[perl,N] ... </code>
# guarantee stability, regardless of algorithm
    use sort 'stable';
    @new = sort { substr($a, 3, 5) cmp substr($b, 3, 5) } @old;

SQL

  • Put code inside <code>[sql,N] ... </code>
CREATE TABLE a (
  id INT PRIMARY KEY,
  value VARCHAR(255)
);
 
INSERT INTO a VALUES (1,"first");
INSERT INTO a VALUES (2,"second");
 
SELECT * FROM a;

HTML

  • Put code inside <code>[html,N] ... </code>
<html>
  <head>
    <title>abc</title>
  </head>
  <body>
    <h1>Header</h1>
    <p>content</p>
  </body>
</html>

Bash

#!/bin/bash
echo "Convert aaa to bbb"
echo "from file $1 to file $2"
sed -e "s/aaa/bbb/g" $1 > $2

Other

Supported lanaguages are:

  • bash,
  • c,
  • cpp,
  • csharp,
  • css,
  • delphi,
  • dos,
  • html,
  • java,
  • javascript,
  • js,
  • pascal,
  • perl,
  • php,
  • pseudocode,
  • python,
  • sql,
  • vb,
  • vbnet,
  • xhtml,
  • xml,
  • and maybe some other - depending on GeShI script and CodeSyntaxHighlight extension
Personal tools