Ignoring Formatting

Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Editor-In-Chief: C. Michael Gibson, M.S., M.D. [1]

Overview

Sometimes there is value in displaying the underlying code so that others can learn how to edit pages.

This is called ignoring formatting.

There are 3 ways to ignore the formatting:

  1. Surrond the text with the words <nowiki> text </nowiki>.
  2. Put a space in front of the text.
  3. Use the editing toolbox to highlight the words and use the 9th button from the left (a w with a red line through it).

Using <nowiki> Tags

Wiki formatting can be ignored by using the <nowiki> and </nowiki> tags. This is particularly handy when writing tutorials on how to use wikimarkup and templates. Examples of the former use can be seen throughout the Editing Help Area. The quick button for inserting non-wikiformatted text is above the edit box, third button from the right.

Here is an example of a normal wiki table that has simply been surrounded by the <nowiki> tags:

{| border="1" |- |bgcolor="#cccccc"|Look at me! I'm a naked table! |}

(Note: normally, any excerpt of code should really be surrounded with the <code> tags, the <pre> tags, or with leading spaces to match W3C convention. The above example was not due to it being a literal representation of what a naked table would look like.)

When you click on "edit", the above looks like this:

<nowiki>
{| border="1"
|-
|bgcolor="#cccccc"| Look at me! I'm a naked table!
|}
</nowiki>

Without the <nowiki> tags, the above wikimarkup will normally produce a bordered table with a grey background color:

Look at me! I'm a naked table!

It should be noted that many people are using a leading space in combination with the <nowiki> tags. This is inefficient. The <pre> tags should be used instead.

Using <pre> Tags

Note that even surrounded by <nowiki> tags, the output text for the table still got mushed onto one line. By default, the wiki ignores line breaks and repeated whitespace. In order to preserve your original line breaks and tabs, you need to use tags to inform the wiki that your material is pre-formatted. If you surround your poem with <pre> and </pre>, the wiki will respect your use of whitespace.

Using the <pre> tag stops the wiki from altering the layout (line breaks and whitespace). In addition, the <pre> tag blocks wiki markup. The <pre> tag will also place your text inside a grey box with a dashed blue outline.

For example, the following code in the edit window:

<pre>
You smash at the barricade. It creaks. 
     ... and again. 
           ... and again. 
                 ... and again. 
                       ... and again. 
You are out of IP hits.
</pre>

comes out as:

You smash at the barricade. It creaks. 
     ... and again. 
           ... and again. 
                 ... and again. 
                       ... and again. 
You are out of IP hits.

Markup symbols and links contained inside the <pre> tags are ignored -- the code inside the blue-dashed box below looks exactly like the same as it appears in the edit window:

'''Markup symbols''' and [[Main Page|links]] <u>contained</u>
     inside a pre-formatted box  using the <pre> tags  
are <br /> ... completely ignored.

Using Leading Space

In order to preserve line breaks and whitespace while still using wiki markup, put a space in front of each line of the block of text. Any series of one or more lines that each begin with a space will be placed inside a blue-dashed box. The layout and whitespace seen in the editing window will be preserved, while all the wiki markup (such as bold, italics, signatures, and links) will be interpreted normally.

For example, the following code in the edit window:

This line doesn't have    leading space.    Whitespace is ignored. 
 This line does have      leading space.    Whitespace is preserved. 
  The following lines ''(including the next one)'' begin with a space.
   
    Text can be '''''formatted''''' and you 
     can have [[Main Page|links]]. (Last changed: ~~~~~)

will produce:

This line doesn't have leading space. Whitespace is ignored.

This line does have      leading space.    Whitespace is preserved. 
 The following lines (including the next one) begin with a space.
  
   Text can be formatted and you 
    can have links. (Last changed: 19:11, 14 April 2006 (BST))

Template:WH Template:WS