13,208
edits
(lowering heading level of the syntax highlighting section; URL:s → interwiki links) |
(→Syntax highlighting: Can also be used for prompts/command lines) |
||
Line 553: | Line 553: | ||
=== Syntax highlighting === | === Syntax highlighting === | ||
''Syntax highlighting'' will make source code more readable. This wiki has support for syntax highlighting of many programming languages, including [[nasal]], XML and C++ (see [[mediawikiwiki:Extension:SyntaxHighlight_GeSHi]] for a more complete list). 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. | ''Syntax highlighting'' will make source code more readable. This wiki has support for syntax highlighting of many programming languages, including [[nasal]], XML and C++ (see [[mediawikiwiki:Extension:SyntaxHighlight_GeSHi]] for a more complete list). 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. | ||
Note that you can use syntax highlighting for command lines as well. | |||
<'''syntaxhighlight''' lang="" ''line start=""'' ''highlight=""'' ''enclose=""''></syntaxhighlight> | <'''syntaxhighlight''' lang="" ''line start=""'' ''highlight=""'' ''enclose=""''></syntaxhighlight> | ||
Line 558: | Line 560: | ||
All attributes but '''lang''' is optional. '''start''' have to be used together with '''line'''. Values must be put inside quotation marks ('''"'''). | 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 '''bash''', '''cpp''', '''dos''', '''nasal''' or '''xml'''. | ||
;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. For example will ''' | ; start: Used together with '''line''' if you want the line numbering to start somewhere else than one. For example will '''42''' start the line numbering from 42 instead of 1. | ||
;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: Used for highlighting a line. Do note that lines are counted from the first line in a snippet disregarding '''start'''. For example will '''3''' highlight the third line in a snippet. | ||
;enclose | ; enclose | ||
: Encloses the source code in a certain html tag. Takes either '''pre''', '''div''' or '''none''', with '''pre''' being the default one. | : Encloses the source code in a certain html tag. Takes either '''pre''', '''div''' or '''none''', with '''pre''' being the default one. | ||
: Using ''' | : Using '''div''' will wrap lines that are too long to fit the screen width so they continue on the following line. | ||
{| class="wikitable" width="100%" | {| class="wikitable" width="100%" |