Help:Formatting: Difference between revisions

Jump to navigation Jump to search
→‎Syntax highlighting: Grammar and clarifiation
(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 attributes some attributes to control how the 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++.  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.


  &lt;'''syntaxhighlight''' lang="" ''line start=""'' ''highlight=""'' ''enclose=""''&gt;&lt;/syntaxhighlight&gt;
  &lt;'''syntaxhighlight''' lang="" ''line start=""'' ''highlight=""'' ''enclose=""''&gt;&lt;/syntaxhighlight&gt;


All attributes but '''lang''' is optional.  '''start''' have to be used together with '''line'''.  Values need to 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 '''xml''', '''nasal''' and '''cpp'''.
;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 one disregarding '''start'''.
;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 arbitrarily starting from line 42.
| 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 start="42" enclose="div">
  <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 start="42" enclose="div">
| <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 example.
| 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">

Navigation menu