Posting source code
From NMR Wiki
Contents |
Introduction
You can post snippets of programming code and scripts using <source> tag (GeSHi extension). Syntax of the programming language will be highlighted for better readability.
Share your scripts and programming tricks!!!
A real life example is here. (it's an extension script for Sparky)
Usage
<source lang="PROGRAMMING_LANGUAGE_NAME">... code ...</source>
Supported languages
These are the languages known by GeSHi that can be used in the lang parameter:
|
|
|
|
Examples
C#
<source lang="csharp"> // Hello World in Microsoft C# ("C-Sharp"). using System; class HelloWorld { public static int Main(String[] args) { Console.WriteLine("Hello, World!"); return 0; } } </source>
Results in:
// Hello World in Microsoft C# ("C-Sharp"). using System; class HelloWorld { public static int Main(String[] args) { Console.WriteLine("Hello, World!"); return 0; } }
PHP
<source lang="php"> <?php // Hello World in PHP echo 'Hello World!'; ?> </source>
Results in:
<?php // Hello World in PHP echo 'Hello World!'; ?>
Python
<source lang="python"> def main(): print "Hello World!" if __name__ == '__main__': main() </source>
Results in:
def main(): print "Hello World!" if __name__ == '__main__': main()
Fortran
bugs:
- comments for fortran77 do not work (line starts with C)
<source lang="fortran"> C * C *testing this srcipt C * c * comments for fortran77 do not work! hello = "Hello World!" if hello .eq. 'test' then !do nothing else !do something x = 1 endif </source>
Results in:
C * C *testing this srcipt C * c * comments for fortran77 do not work! hello = "Hello World!" if hello .eq. 'test' then !do nothing else !do something x = 1 endif