Formatting Code

From C3LearningLabs

The following markup will display text and code in the wiki.


Unformatted Text

The <nowiki> tag will produce unformatted text on the page.
<nowiki> tags stop parsing of wiki markup, except HTML characters (e.g., for special characters).

<nowiki>  <Map><br>IDName = "Akka" OSMFile = "Akka.xml"/><br> </nowiki>

The above code produces the following result on the page:

<Map><br>IDName = "Akka" OSMFile = "Akka.xml" /><br>


Unformatted Text Block

The <pre> tag will produce unformatted text block on the page. The <pre> tag stop parsing of all wiki and html markup, except HTML characters (e.g., for special characters).

 <pre>
  <u><b> External links </b></u>
  * https://en.wikipedia.org/wiki/Template:Col-break/examples
  * https://en.wikipedia.org/wiki/Help:Columns
  ''End''
 </pre>

The above code produces the following result on the page:

<u><b> External links </b></u>
* https://en.wikipedia.org/wiki/Template:Col-break/examples
* https://en.wikipedia.org/wiki/Help:Columns
''End''




Text Block

A text block that performe wiki and html formatting can be created when the text lines starts with a space in the first column. The block will be maintained as long as the first column is a space.

 This text is in a text block.
 Text in a text <big>'''Block'''</big> can be formatted
 with normal <u>wiki markup</u>. 
 C<sup>3</sup>Fire
 https://www.mediawiki.org

The above code produces the following result on the page:

This text is in a text block.
Text in a text Block can be formatted
with normal wiki markup. 
C3Fire
https://www.mediawiki.org




One line code

The <code> tag will produce a line of code text in a small area on the page.

<code> LatitudeNorth = "67.728190" </code>

The above code produces the following result on the page:

LatitudeNorth = "67.728190"


The <nowiki> tag will produce a line of code where no wiki syntax processing are done.

<nowiki> no ''markup'' </nowiki>

The above code produces the following result on the page:

no ''markup''


Multiple lines of code

The <source> tag will produce multiple lines of code text in an area on the page.

 <source>
 <Map
      IDName = "Akka" 
      LatitudeNorth = "67.728190"
      LongitudeEast = "18.178253" />
</source>

The above code produces the following result on the page:

<Map
      IDName = "Akka" 
      LatitudeNorth = "67.728190"
      LongitudeEast = "18.178253" />


Syntax Highlighting

The <syntaxhighlight> tag will produce multiple lines of source code with syntax highlight text in an area on the page.

<syntaxhighlight lang="xml">
<Map
      IDName = "Akka" 
      LatitudeNorth = "67.728190"
      LatitudeSouth = "67.421200"
      LongitudeEast = "18.178253"
      LongitudeWest = "16.747284"
      Comment = "Where I want to be"
      OSMFile = "Akka-OSM.xml" />
</syntaxhighlight>

The above code produces the following result on the page:

<Map
      IDName = "Akka" 
      LatitudeNorth = "67.728190"
      LatitudeSouth = "67.421200"
      LongitudeEast = "18.178253"
      LongitudeWest = "16.747284"
      Comment = "Where I want to be"
      OSMFile = "Akka-OSM.xml" />

Source code of various programming and markup languages can be formatted using source element, which leads to colored syntax of the code.

Line

The line attribute enables line numbers.

<syntaxhighlight lang="xml" line>
<Map
      IDName = "Akka" 
      LatitudeNorth = "67.728190"
      LatitudeSouth = "67.421200"
      LongitudeEast = "18.178253"
      LongitudeWest = "16.747284"
      Comment = "Where I want to be"
      OSMFile = "Akka-OSM.xml" />
</syntaxhighlight>

The above code produces the following result on the page:

1 <Map
2       IDName = "Akka" 
3       LatitudeNorth = "67.728190"
4       LatitudeSouth = "67.421200"
5       LongitudeEast = "18.178253"
6       LongitudeWest = "16.747284"
7       Comment = "Where I want to be"
8       OSMFile = "Akka-OSM.xml" />

Start

The start attribute (in combination with line) defines the first line number of the code block. For example, line start="55" will make line numbering start at 55.

<syntaxhighlight lang="xml" line start="55">
<Map
      IDName = "Akka" 
      LatitudeNorth = "67.728190"
      LatitudeSouth = "67.421200"
      LongitudeEast = "18.178253"
      LongitudeWest = "16.747284"
      Comment = "Where I want to be"
      OSMFile = "Akka-OSM.xml" />
</syntaxhighlight>

The above code produces the following result on the page:

55 <Map
56       IDName = "Akka" 
57       LatitudeNorth = "67.728190"
58       LatitudeSouth = "67.421200"
59       LongitudeEast = "18.178253"
60       LongitudeWest = "16.747284"
61       Comment = "Where I want to be"
62       OSMFile = "Akka-OSM.xml" />

Highlight

The highlight attribute specifies one or more lines that should be marked (by highlighting those lines with a different background color). You can specify multiple line numbers separated by commas (for example, highlight="1,4,8") or ranges using two line numbers and a hyphen (for example, highlight="5-7").

<syntaxhighlight lang="xml" line start="55" highlight="1,3-6">
<Map
      IDName = "Akka" 
      LatitudeNorth = "67.728190"
      LatitudeSouth = "67.421200"
      LongitudeEast = "18.178253"
      LongitudeWest = "16.747284"
      Comment = "Where I want to be"
      OSMFile = "Akka-OSM.xml" />
</syntaxhighlight>

The above code produces the following result on the page:

55 <Map
56       IDName = "Akka" 
57       LatitudeNorth = "67.728190"
58       LatitudeSouth = "67.421200"
59       LongitudeEast = "18.178253"
60       LongitudeWest = "16.747284"
61       Comment = "Where I want to be"
62       OSMFile = "Akka-OSM.xml" />

References

https://en.wikibooks.org/wiki/MediaWiki_User_Guide/Text_Formatting

https://www.mediawiki.org/wiki/Help:Formatting

https://en.wikipedia.org/wiki/Help:Wiki_markup

https://www.mediawiki.org/wiki/Extension:SyntaxHighlight