Difference between revisions of "MediaWiki/Syntax highlighting"
m (MediaWiki/Syntax highlighting moved to MediaWiki/Syntax highlighting: not to be confused with the general article on Syntax Highlighting) |
|||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Writing good code follows good coding standards. On top of coding standards, syntax highlighting reveals the code making it easier to read (and learn). | Writing good code follows good coding standards. On top of coding standards, syntax highlighting reveals the code making it easier to read (and learn). | ||
− | There is a [http://qbnz.com/highlighter/faq.php Generic Syntax Highlighter] or GeSHi for short which is available as a Debian package (sudo apt-get install php-geshi). | + | There is a [http://qbnz.com/highlighter/faq.php Generic Syntax Highlighter] or GeSHi for short which is available as a Debian package (sudo apt-get install php-geshi). Adding [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi Brion Vibber's extension] (is better than this alternate [http://meta.wikimedia.org/wiki/GeSHiCodeTag_Extension GeSHi Code Tag] extension because Brion's just registers one new tag: 'source' and uses the extension parameter passing available since MW 1.5) extension to allows it to be used in this wiki. |
− | + | Incorporating it into Mediawiki is just a matter of creating/configuring the extension and including it in LocalSettings. | |
− | |||
− | |||
− | |||
− | |||
== Usage == | == Usage == | ||
− | + | There are two code tags that you can use: | |
− | + | # '''Simple Tag Format:''' <nowiki><'language'>source code here</'language'></nowiki> | |
+ | # '''Advanced Tag Format:''' <nowiki><code ['language'|list] [n] >source code here</code></nowiki> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | '''Tag Examples''' | |
− | + | ''- simple code tag'' | |
+ | <br> | ||
+ | <nowiki> | ||
+ | <php> echo "Hello World"; </php> | ||
+ | </nowiki> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ''- advanced code tag'' | |
− | + | <br> | |
− | + | <nowiki> | |
− | + | <code php> | |
− | + | echo "Hello World"; | |
− | + | </code> | |
− | + | </nowiki> | |
− | |||
− | + | ||
− | + | ''- advanced code tag with line numbers'' | |
− | + | <br> | |
− | + | <nowiki> | |
+ | <code php n> | ||
+ | echo "Hello World"; | ||
+ | </code> | ||
+ | </nowiki> | ||
− | |||
− | |||
+ | ''- default code tag'' | ||
+ | <br> | ||
+ | <nowiki> | ||
+ | <code> | ||
+ | echo "Hello World"; | ||
+ | </code> | ||
+ | </nowiki> | ||
+ | |||
+ | |||
+ | ''- display a list of supported languages'' | ||
+ | <br> | ||
+ | <nowiki> | ||
+ | <code list></code> | ||
+ | </nowiki> | ||
== Supported Languages == | == Supported Languages == | ||
− | + | <code list></code> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Documentation == | == Documentation == | ||
See http://qbnz.com/highlighter/geshi-doc.html for the extensive documentation. GeSHi is used in a number of other software projects like | See http://qbnz.com/highlighter/geshi-doc.html for the extensive documentation. GeSHi is used in a number of other software projects like | ||
+ | * Dokuwiki - An advanced wiki engine | ||
+ | * gtk.php.net - Their manual uses GeSHi for syntax highlighting | ||
+ | * WordPress - A powerful blogging system* | ||
+ | * PHP-Fusion - A constantly evovling CMS | ||
+ | * SQL Manager - A Postgres DBAL | ||
+ | * Mambo - A popular open source CMS | ||
+ | * MediaWiki - A leader in Wikis* | ||
+ | * TikiWiki - A megapowerful Wiki/CMS | ||
+ | * TikiPro - Another powerful Wiki based on Tikiwiki | ||
+ | * RWeb - A site-building tool | ||
+ | If you want to use it in OASIS projects besides this wiki, then start with the documentation. | ||
+ | |||
[[Category:Development]] | [[Category:Development]] | ||
[[Category:Wiki]] | [[Category:Wiki]] |
Revision as of 20:57, 3 June 2007
Writing good code follows good coding standards. On top of coding standards, syntax highlighting reveals the code making it easier to read (and learn).
There is a Generic Syntax Highlighter or GeSHi for short which is available as a Debian package (sudo apt-get install php-geshi). Adding Brion Vibber's extension (is better than this alternate GeSHi Code Tag extension because Brion's just registers one new tag: 'source' and uses the extension parameter passing available since MW 1.5) extension to allows it to be used in this wiki.
Incorporating it into Mediawiki is just a matter of creating/configuring the extension and including it in LocalSettings.
Usage[edit | edit source]
There are two code tags that you can use:
- Simple Tag Format: <'language'>source code here</'language'>
- Advanced Tag Format: <code ['language'|list] [n] >source code here</code>
Tag Examples
- simple code tag
<php> echo "Hello World"; </php>
- advanced code tag
<code php>
echo "Hello World";
</code>
- advanced code tag with line numbers
<code php n>
echo "Hello World";
</code>
- default code tag
<code>
echo "Hello World";
</code>
- display a list of supported languages
<code list></code>
Supported Languages[edit | edit source]
Documentation[edit | edit source]
See http://qbnz.com/highlighter/geshi-doc.html for the extensive documentation. GeSHi is used in a number of other software projects like
- Dokuwiki - An advanced wiki engine
- gtk.php.net - Their manual uses GeSHi for syntax highlighting
- WordPress - A powerful blogging system*
- PHP-Fusion - A constantly evovling CMS
- SQL Manager - A Postgres DBAL
- Mambo - A popular open source CMS
- MediaWiki - A leader in Wikis*
- TikiWiki - A megapowerful Wiki/CMS
- TikiPro - Another powerful Wiki based on Tikiwiki
- RWeb - A site-building tool
If you want to use it in OASIS projects besides this wiki, then start with the documentation.