Difference between revisions of "Syntax Highlighting Examples"

From Second Life Wiki
Jump to navigation Jump to search
(New page: == PHP Test == Text before code. <source lang="php"> <?php $v = "string"; // sample initialization ?> html text <? echo $v; // end of php code ?> </source> Text after ...)
 
Line 1: Line 1:
== PHP Test ==
This extension enables including code with syntax highlighting.  You can use the following tags:
 
<pre>
"actionscript-french", "actionscript", "ada", "apache", "applescript",
"asm", "asp", "bash", "c", "caddcl", "cadlisp", "cpp", "csharp",
"css", "c_mac", "d", "delphi", "diff", "dos", "eiffel",
"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>
 
== PHP ==


Text before code.
Text before code.
<source lang="php">
<php><?php
<?php
     $v = "string";    // sample initialization
     $v = "string";    // sample initialization
?>
?>
Line 9: Line 21:
<?
<?
     echo $v;        // end of php code
     echo $v;        // end of php code
?>  
?> </php>
</source>
Text after code.
Text after code.


== Python Test ==
== Python ==
   
   
Text before code.
Text before code.
<source lang="python">
<python> # Hello World in Python
# Hello World in Python


  def main():
  def main():
Line 23: Line 33:
   
   
  if __name__ == '__main__':
  if __name__ == '__main__':
     main()
     main()</python>
</source>
Text after code.
 
=== Example of code with leading spaces ===
Note that the syntax highlighting does not happen, even though the code is tagged properly.
<source lang="python">
# Hello World in Python
 
def main():
    print "Hello World!"
 
if __name__ == '__main__':
    main()
</source>
Text after code.
Text after code.


== c++ test ==
== C++ ==


Text before code.
Text before code.


<source lang="cpp">
<cpp>#include <iostream>
#include <iostream>


int main(int argc, char** argv)
int main(int argc, char** argv)
Line 51: Line 46:
     std::cout << "hai, can i haz c++ nao?" << std::endl;
     std::cout << "hai, can i haz c++ nao?" << std::endl;
     return 0;
     return 0;
}
}</cpp>
</source>


Text after code.
Text after code.
<source lang="cpp">
#include <iostream>
int main(int argc, char** argv)
{
    std::cout << "hai, can i haz c++ nao?" << std::endl;
    return 0;
}
</source>


== HTML Test (note: lang="html4strict") ==
== HTML ==


Text before code.
Text before code.
<source lang="html4strict">
<html4strict><h1>OMG Look at This</h1>
<h1>OMG Look at Yoz</h1>
<p class="youknowsit">Wait where did he get that penguin from?</p></html4strict>
<p class="youknowsit">Wait where did he get that penguin from</p>
</source>
Text after code.
Text after code.

Revision as of 12:48, 18 May 2009

This extension enables including code with syntax highlighting. You can use the following tags:

"actionscript-french", "actionscript", "ada", "apache", "applescript", 
"asm", "asp", "bash", "c", "caddcl", "cadlisp", "cpp", "csharp", 
"css", "c_mac", "d", "delphi", "diff", "dos", "eiffel", 
"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");

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.