Difference between revisions of "Syntax Highlighting Examples"

From Second Life Wiki
Jump to navigation Jump to search
Line 1: Line 1:
This extension enables including code with syntax highlighting.  You can use the following tags:
== Overview ==
 
This is a rather old extension that enables including code with syntax highlighting.  To use, it, enclose your code in tags like this
<pre>
<pre>
"actionscript-french", "actionscript", "ada", "apache", "applescript",
<Language>
"asm", "asp", "bash", "c", "caddcl", "cadlisp", "cpp", "csharp",
....
"css", "c_mac", "d", "delphi", "diff", "dos", "eiffel",
</Language>
"freebasic", "gml", "html4strict", "ini", "inno", "java", "javascript",
"lisp", "lua", "matlab", "mpasm", "nsis", "objc", "ocaml-brief",
"ocaml", "oobas", "oracle8", "pascal", "perl", "php-brief", "php",
"python", "qbasic", "ruby", "scheme", "sdlbasic", "smarty", "sql",
"vb", "vbnet", "vhdl", "visualfoxpro", "xml");
</pre>
</pre>
where Language is the code for the programming or markup language being used.
The [http://www.mediawiki.org/wiki/Extension:GeSHiHighlight_(Ajqnic) documentation] lists a large number of supported languages, but the ones most likely to be useful here are
* cpp: C++
* bash: Bash shell
* html4strict: HTML
* javascript: Javascript
* perl: Perl
* php: PHP
* python: Python
* sql: SQL
* xml: XML


== PHP ==
== PHP ==

Revision as of 13:56, 18 May 2009

Overview

This is a rather old extension that enables including code with syntax highlighting. To use, it, enclose your code in tags like this

<Language>
 ....
</Language>

where Language is the code for the programming or markup language being used.

The documentation lists a large number of supported languages, but the ones most likely to be useful here are

  • cpp: C++
  • bash: Bash shell
  • html4strict: HTML
  • javascript: Javascript
  • perl: Perl
  • php: PHP
  • python: Python
  • sql: SQL
  • xml: XML

PHP

Text before code. <php><?php

   $v = "string";    // sample initialization

?> html text <?

   echo $v;         // end of php code

?> </php> Text after code.

Python

Text before code. <python> # Hello World in Python

def main():
    print "Hello World!"

if __name__ == '__main__':
    main()</python>

Text after code.

C++

Text before code.

<cpp>#include <iostream>

int main(int argc, char** argv) {

   std::cout << "hai, can i haz c++ nao?" << std::endl;
   return 0;

}</cpp>

Text after code.

HTML

Text before code.

<html4strict>

OMG Look at This

Wait where did he get that penguin from?

</html4strict>

Text after code.