Syntax Highlighting Examples

From Second Life Wiki

Second Life Wiki > Help Portal > Wiki > Syntax Highlighting Examples
Jump to: navigation, search

Template:Needs Translation/de Template:Needs Translation/es Template:Needs Translation/el Template:Needs Translation/fr Template:Needs Translation/he Template:Needs Translation/it Template:Needs Translation/ja Template:Needs Translation/ko Template:Needs Translation/nl Template:Needs Translation/hu Template:Needs Translation/no Template:Needs Translation/da Template:Needs Translation/sv Template:Needs Translation/tr Template:Needs Translation/pl Template:Needs Translation/pt Template:Needs Translation/ru Template:Needs Translation/uk Template:Needs Translation/zh-Hans Template:Needs Translation/zh-Hant

Contents

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
    $v = "string";    // sample initialization
?>
html text
<?
    echo $v;         // end of php code
?>

Text after code.

Python

Text before code.

 # Hello World in Python
 
 def main():
     print "Hello World!"
 
 if __name__ == '__main__':
     main()

Text after code.

C++

Text before code.

#include <iostream>
 
int main(int argc, char** argv)
{
    std::cout << "hai, can i haz c++ nao?" << std::endl;
    return 0;
}

Text after code.

HTML

Text before code.

<h1>OMG Look at This</h1>
<p class="youknowsit">Wait where did he get that penguin from?</p>

Text after code.

In other languages