Basic formatting tips

From Wowww mediawiki

Jump to: navigation, search

MediaWiki uses its own codes for marking up pages. People accustomed to HTML may recognize the way certain elements are built up. The use of HTML itself is strongly discouraged in favor of unified mark-up and styling.

Contents

MediaWiki explains

This page contains a summary of some essential mark-up codes. You can find more codes, information and examples on MediaWiki.org. Some useful links:

Headers

Headers are formatted using equal signs (=). Adding a header creates a new section on a page, which can be individually edited when pressing the 'Edit' button to the right of the header. On larger pages, table of contents are automatically created and contain anchors links to each header on the page.

To add a header, simply type the desired header text and surround it with an equal amount of equal signs on each side. The first header of a large section will be surrounded by two equal signs on each side. Each added equal sign will make the header go one level deeper.

For example:

== Header 1 ==
=== Header 1.1 ===
==== Header 1.1.1 ====
==== Header 1.1.2 ====
== Header 2 ==

Text mark-up

Text can be made italicized and/or bold by surrounding a text with apostrophes. Use two apostrophes for italicized text, three for bold text and five for both.

For example:

  • ''Text'' gives Text
  • '''Text''' gives Text
  • '''''Text''''' gives Text

Links

MediaWiki distinguishes between two kinds of links: internal and external links.

Internal links

Internal links refer to pages on the same wiki. You can create a link by typing the name of the page you wish to link to, surrounded by two square brackets on each side. If you wish to link to a category page, you will have to type the page name as :Category:Category name. If the first colon is left out of the name, the link turns into a category tag instead.

Optionally, after the page name and before the closing brackets, you can type a label name. You will have to separate the page name and the display name by a vertical bar (|). If you do not supply a display name, the link will display the title of the page it links to. It does not matter whether the page name contains spaces or underscores, as these will both be accepted by MediaWiki.

Appending letters directly to the link (behind the closing brackets) will cause these letters to be part of the link title. This is mainly useful when you quickly want to add one character (often an 's' for plural forms) to the name of the page you're linking to.

MediaWiki will also mark links to existing and non-existing pages differently. This way, broken links can more easily be identified.

For example:

[[Drupal]]
[[Drupal|Label]]
[[:Category:Drupal]]
[[:Category:Drupal|Label]]
[[Drupal]]asdasdasd

Produces:

External links

Unlike internal links, external links are only surrounded by one square bracket on each side. Another difference is that the link and its title are separated by a space and not a vertical bar. If the link title is omitted, it is replaced by a number. This number starts as 1 and is increased with every title-less link.

You can also choose to omit the square brackets surrounding the external link. In this case, a link will automatically displayed and the link text will be equal to the URL.

Each link is also followed by an icon which marks the link as pointing to somewhere outside of the wiki. Note that the trick of appending characters to the end of the link, like with internal links, does not work with external links.

For example:

[http://drupal.org/]
[http://drupal.org/]
[http://drupal.org/ Drupal.org]

Produces:

Lists

There are three main ways to create lists. You have ordered (numbered), unordered (bulleted) and definition lists.

These three list types can be nested inside each other, provided they are marked up correctly.

Ordered and unordered lists

These two types of lists are created the same way, with the only difference the way they are called. Ordered lists are created using a hash sign (#), where unordered lists are created using asterisks (*).

To create a list, type either the hash sign or asterisk, followed by the text you want to display.

You can also nest lists in other lists. For both lists goes that you type the hash sign or asterisk, preceded by the sign that matches its parent.

For example:
* Point 1
* Point 2
* Point 3
 
# Point 1
# Point 2
# Point 3
 
# Point 1
## Point 1.1
### Point 1.1.1
## Point 1.2
# Point 2
# Point 3
 
* Point 1
*# Point 1.1
*## Point 1.1.1
*# Point 1.2
* Point 2
* Point 3
Produces:
  • Point
  • Point
  • Point
 
  1. Point 1
  2. Point 2
  3. Point 3
 
  1. Point 1
    1. Point 1.1
      1. Point 1.1.1
    2. Point 1.2
  2. Point 2
  3. Point 3
 
  • Point
    1. Point 1
      1. Point 1.1
    2. Point 2
  • Point
  • Point

Definition lists

MediaWiki mark-up uses a semicolon (;) for making an entire line of text bold, where a colon (:) is used to indent text. Due to the nature of this mark-up, these signs can easily be combined to create definition lists.

To create definition lists, use the semicolon to mark up a term and a colon to mark up its definition.

For example:
; Term
: Definition
; Term 2
: Definition line 1
: Definition line 2
: Definition line 3
 
; Term
: Definition
; Term 2
: Definition with list
:* Point
:* Point
Produces:
Term
Definition
Term 2
Definition line 1
Definition line 2
Definition line 3
 
Term
Definition
Term 2
Definition with list
  • Point
  • Point

Tables

Table are more complicated to mark up than most wiki parts, as they consist of multiple lines of code and support many variants of styling. The codes use characters like curly braces ({, }), pipes (|), exclamation marks (!) and hyphens (-).

Basically, a table consists of this:

  • {| and |} are the start and end tags of a table;
  • |- indicates the start of a new row;
  • ! is the start of a header cell;
  • | is the start of a normal cell;
    • is also used to separate a cell and its contents, should extra attributes be added to a cell;
  • colspan="...", rowspan="..." and style="..." are among the attributes that can be used in a wiki table;
    • These are placed behind the table start tag, behind the new row indicator and between the start tag of a cell and an extra pipe (before the cell's contents).

For example:

{| style="border: 1px solid #000"
! A column header
! style="color: #0ff" | A styled column header
|-
| A cell
| style="color: #f0f" | A styled cell
|- style="background-color: #999; color: #ff0"
| colspan="2" | A cell spanning two columns in a styled row
|}

Produces:

A column header A styled column header
A cell A styled cell
A cell spanning two columns in a styled row

Categories

It is good wiki practice to assign at least one category to each page and category. In theory, each page should directly but preferably indirectly be linked to the same, main, category. Often this category is called 'Browse'.

To add a page or category to a category, place the following code into its source:

[[Category:Name of category]]
[[Category:Name of category|Text that will (only) visibly replace 'Name of category']]

A link to the page will be placed in another page called Category:Name of category, under the first letter of its page name. If you wish to list a page under a different letter, add another argument to the category link. This is seen in the second example in the code above.

Redirects

You can redirect wiki pages to other pages within the same wiki. It is possible to delete pages, though when a user is not allowed to, or it is better practice to keep a certain page, one may wish to use these redirects.

To create a redirect, replace a page's code with the following:

#REDIRECT [[page to redirect to]]

For administration purposes, you can add a redirecting page to the category Category:Redirect.

Other formatting

  • <nowiki></nowiki> tags are used to print special MediaWiki code, rather than executing it.
  • <code></code> tags are used to display (source) code in a special code block. It also prevents the execution of MediaWiki code. This is often used in coding examples.
Personal tools