13,208
edits
(editing → formatting + some minor changes) |
(→Syntax highlighting: Grammar and clarifiation) |
||
Line 528: | Line 528: | ||
== Syntax highlighting == | == Syntax highlighting == | ||
''Syntax highlighting'' will source code more readable. This wiki has support for many programming languages, including [[nasal]], XML and C++. The source code to be highlighted is put between <nowiki><syntaxhighlight></nowiki> tags. The tag can be given | ''Syntax highlighting'' will make source code more readable. This wiki has support for syntax highlighting of many programming languages, including [[nasal]], XML and C++. The source code snippet to be highlighted is put between <nowiki><syntaxhighlight></nowiki> tags. The tag can be given some attributes to control how the source code appears. | ||
<'''syntaxhighlight''' lang="" ''line start=""'' ''highlight=""'' ''enclose=""''></syntaxhighlight> | <'''syntaxhighlight''' lang="" ''line start=""'' ''highlight=""'' ''enclose=""''></syntaxhighlight> | ||
All attributes but '''lang''' is optional. '''start''' have to be used together with '''line'''. Values | All attributes but '''lang''' is optional. '''start''' have to be used together with '''line'''. Values must be put inside quotation marks ('''"'''). | ||
;lang: The language to be highlighted, for example ''' | ;lang: The language to be highlighted, for example '''lang="nasal"''', '''lang="xml"''' and '''lang="cpp"'''. | ||
;line: Use line numbering. | ;line: Use line numbering. | ||
;start: Used together with '''line''' if you want the line numbering to start somewhere else than one. | ;start: Used together with '''line''' if you want the line numbering to start somewhere else than one. For example will '''line start="42"''' start the line numbering from 42 instead of 1. | ||
;highlight: Used for highlighting a line. Do note that lines are counted from | ;highlight: Used for highlighting a line. Do note that lines are counted from the first line in a snippet disregarding '''start'''. For example will '''highlight="3"''' highlight the third line in a snippet. | ||
;enclose | ;enclose | ||
Line 566: | Line 566: | ||
|- | |- | ||
| XML highlighting, here with line numbering | | XML highlighting, here with line numbering, but without specifying the line number of the first line. | ||
| | | | ||
<pre style="white-space: pre-wrap;"><syntaxhighlight lang="xml" line | <pre style="white-space: pre-wrap;"><syntaxhighlight lang="xml" line enclose="div"> | ||
<animation> | <animation> | ||
<object-name>Object</object-name> | <object-name>Object</object-name> | ||
Line 575: | Line 575: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</pre> | </pre> | ||
| <syntaxhighlight lang="xml" line | | <syntaxhighlight lang="xml" line enclose="div"> | ||
<animation> | <animation> | ||
<object-name>Object</object-name> | <object-name>Object</object-name> | ||
Line 582: | Line 582: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|- | |- | ||
| C++ highlighting, arbitrarily starting from 46, and highlighting 4th line in the | | C++ highlighting, arbitrarily starting from line 46, and highlighting the 4th line in the snippet. | ||
| | | | ||
<pre style="white-space: pre-wrap;"><syntaxhighlight lang="cpp" line start="46" highlight="4" enclose="div"> | <pre style="white-space: pre-wrap;"><syntaxhighlight lang="cpp" line start="46" highlight="4" enclose="div"> |