Syntax Highlighting Examples

From Second Life Wiki
Revision as of 13:40, 18 May 2009 by Rand Linden (talk | contribs) (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 ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

PHP Test

Text before code.

<?php
    $v = "string";    // sample initialization
?>
html text
<?
    echo $v;         // end of php code
?>

Text after code.

Python Test

Text before code.

 # Hello World in Python

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

Text after code.

Example of code with leading spaces

Note that the syntax highlighting does not happen, even though the code is tagged properly.

 # Hello World in Python

 def main():
     print "Hello World!"

 if __name__ == '__main__':
     main()

Text after code.

c++ test

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.

#include <iostream>

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

HTML Test (note: lang="html4strict")

Text before code.

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

Text after code.