Mediawiki syntax

From wikinotes

For More info: http://www.mediawiki.org/wiki/Help:Formatting


Font

Font
''italic''
italic
'''bold'''
bold
'''''bold & italic''''' 
bold & italic
<pre> codeblock, text formatting </pre>
 codeblock no text formatting 
Inline Code Ex: <code> :w !sudo tee %</code> Inline Code Ex: :w !sudo tee %
 
<syntaxhighlight lang="python" line start="55">

  # code block with syntax highlighting
  # syntaxhighlight geshi extension

  for i in list :
     print i

</syntaxhighlight>
# code block with syntax highlighting
# syntaxhighlight geshi extension

for i in list :
   print i

Math

NOTE:

to render math you must set $wgUseTeX = true; in your LocalSettings.php.
and have installed texvc.

Mediawiki supports rendering math using a subset of tex.
See official docs

<math>\exp_a b = a^b, \exp b = e^b, 10^m</math>

Text Formatting

Text Formatting
 
# list A
## list A1
## list A2
# list B
  1. list A
    1. list A1
    2. list A2
  2. list B
* list A
** list A1
** list A2
* list B
  • list A
    • list A1
    • list A2
  • list B
 ---- 
linebreak

Tables

Tables
{| class="wikitable"
| apple || orange || pear
|-
| peas || broccoli || carrot
|}
standard table
{|
| {| class="wikitable"
!colspan="3"|Table Title
|-
| apple || orange || pear
|}
table with headings (can have multiple)
{| class="wikitable sortable"
|-
! Country !! Currency
|-
| Canada || CAD
|-
| USA || USD
|-
|}
A sortable table (multi-col sort by clicking one sort, then shift+clicking another)

Columns

manual flow

Mediawiki allows you to use a subset of html within your pages. Using this, you can setup columns to containing anything else.

<div style="width:80%">
<div style="float:left; margin:0px auto; width:33%">
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
</div>
<div style="float:left; margin:0px auto; width:33%">
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
</div>
<div style="float:left; margin:0px auto; width:33%">
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
</div>
</div>
<div style="clear:both;"></div>

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

automatic flow

<div style="
       -moz-column-count: 2;
       -moz-column-gap: 20px;
       -webkit-column-count: 2;
       -webkit-column-gap: 20px;
">
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
</div>

To Make this easier to use/maintain, I created a CSS class you can use.

<div class="cols2">
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
The quick brown fox jumps over the lazy dog.
</div>

<div class="cols2">...</div>

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

<div style="...">...</div>

The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.

Collapsible Elements

<div class="toccolours mw-collapsible mw-collapsed">
This text will always appear.

<div class="mw-collapsible-content">
This text appears only when collapsed.

</div>
</div>


This text will always appear.

This text appears only when collapsed.

Navigation

Navigation
<span style="float:right">__TOC__</span>
Table Of Contents
----
line break
= header 1 =
== header 2 ==
=== header 3 ===
Create Headers (automatically linked to in table of contents)
[[internal wiki link]] 
Create Page/Link to existing Page
[[Internal Page#Some Header|New Title]]
Create Link to Existing Page's Header.
[http://{{SERVERNAME}}/README README FILE]
Create Link to File on Webserver {{SERVERNAME}} gets expanded to server name by mediawiki

README FILE

 [https://example.com/blah external web link] 
Link to external website

Redirect / Alias

#REDIRECT [[pagename]]

Images

[[File:Lavos.png]]
Use Image. (click on link to add)
[[File:Lavos.png|60x60px]]
Resize Image.

Templates (tags)

{{todo| you should really do...}}
use template todo for text
/* template contents example */

<div style="background: #E0EFFF">
<span style="color:     #0077AA"> 
'''Todo:'''<br>
</span>
{{{1}}}
</div>
  • text before the first pipe indicates the type of template
  • pipes that follow separate parameters. (ex: you may want a title, and body)
https://www.mediawiki.org/wiki/Help:Templates