Difference between revisions of "Help:Syntax Highlighting"
Jump to navigation
Jump to search
m (→See also) |
m |
||
Line 1: | Line 1: | ||
− | If you want to include source code snippets in your articles, you can make use of the <code><nowiki><source /></nowiki></code> tag to automatically highlight the text according to the selected language to make it | + | If you want to include source code snippets in your articles, you can make use of the <code><nowiki><source /></nowiki></code> tag to automatically highlight the text according to the selected language to make it easier readable. |
==Usage== | ==Usage== | ||
Line 27: | Line 27: | ||
There is a variety of parameters you can use: | There is a variety of parameters you can use: | ||
;lang: This is a keyword to specify the language you want to have highlighted. Use <code>scm</code> for [[main.scm|mission script]] code ([[Sanny Builder]] syntax, provided by [[User:Seemann|Seemann]]); for the other available languages see [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi#Supported_languages this list]. | ;lang: This is a keyword to specify the language you want to have highlighted. Use <code>scm</code> for [[main.scm|mission script]] code ([[Sanny Builder]] syntax, provided by [[User:Seemann|Seemann]]); for the other available languages see [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi#Supported_languages this list]. | ||
− | ;line: With this parameter set line numbers will show up at the start of each line. | + | ;line: With this parameter set, line numbers will show up at the start of each line. |
;start: If you are quoting from the middle of a file, use this to set the offset for line numbers. | ;start: If you are quoting from the middle of a file, use this to set the offset for line numbers. | ||
− | ;highlight: To highlight certain lines of the code | + | ;highlight: To highlight certain lines of the code snippet, this parameter takes a list of line ranges. |
==Example== | ==Example== | ||
Line 66: | Line 66: | ||
==See also== | ==See also== | ||
* [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi SyntaxHighlight_GeSHi] wiki extension documentation | * [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi SyntaxHighlight_GeSHi] wiki extension documentation | ||
− | * [http://qbnz.com/highlighter/ GeSHi | + | * [http://qbnz.com/highlighter/ GeSHi homepage] |
Latest revision as of 23:35, 7 December 2008
If you want to include source code snippets in your articles, you can make use of the <source />
tag to automatically highlight the text according to the selected language to make it easier readable.
Contents
Usage
In the wiki markup, you can use <source>...</source>
tags.
Example for PHP:
<source lang="php"> <?php // Hello World in PHP echo 'Hello World!'; ?> </source>
Results in:
<?php
// Hello World in PHP
echo 'Hello World!';
?>
Parameters
There is a variety of parameters you can use:
- lang
- This is a keyword to specify the language you want to have highlighted. Use
scm
for mission script code (Sanny Builder syntax, provided by Seemann); for the other available languages see this list. - line
- With this parameter set, line numbers will show up at the start of each line.
- start
- If you are quoting from the middle of a file, use this to set the offset for line numbers.
- highlight
- To highlight certain lines of the code snippet, this parameter takes a list of line ranges.
Example
The following example shows scm code, with line numbers starting at 10, and lines 2, 7 and 9 to 11 highlighted:
<source lang="scm" line start="10" highlight="2, 7, 9-11"> :LoadModel 0247: load_model #BFORI :CheckModel 0001: wait 0 ms 00D6: if 0 0248: model #BFORI available 004D: jump_if_false @CheckModel 009A: 0@ = create_actor_pedtype 5 model #BFORI at 0.0 0.0 0.0 0249: release_model #BFORI 004E: end_thread </source>
Results in:
:LoadModel
0247: load_model #BFORI
:CheckModel
0001: wait 0 ms
00D6: if 0
0248: model #BFORI available
004D: jump_if_false @CheckModel
009A: 0@ = create_actor_pedtype 5 model #BFORI at 0.0 0.0 0.0
0249: release_model #BFORI
004E: end_thread
See also
- SyntaxHighlight_GeSHi wiki extension documentation
- GeSHi homepage