Help:Wiki markup: Difference between revisions

From Tardis Wiki, the free Doctor Who reference
Line 369: Line 369:
:<tt><nowiki>{{#titleparts:</nowiki> Talk:An Unearthly Child/Episodes/Cave of Skulls <nowiki>| | -1 }}</nowiki></tt> &rarr; ''' [[{{#titleparts: Talk:An Unearthly Child/Episodes/Cave of Skulls | | -1 }}]]'''  
:<tt><nowiki>{{#titleparts:</nowiki> Talk:An Unearthly Child/Episodes/Cave of Skulls <nowiki>| | -1 }}</nowiki></tt> &rarr; ''' [[{{#titleparts: Talk:An Unearthly Child/Episodes/Cave of Skulls | | -1 }}]]'''  


Now, you might be thinking, how does that save any time whatsoever?  I could just type <nowiki>[[Cave of Skulls]]</nowiki> and be done with it.  And yes, you could.  But '''within a template''' this becomes extremely powerful.  With some additional coding, you could fairly easily create something that would work on any page '''automatically''' — without you having to type it on every single story page on the wiki.   
Now, you might be thinking, "How does that save any time whatsoever?  I could just type <nowiki>[[Cave of Skulls]]</nowiki> and be done with it." And yes, you could.  But '''within a template''' this becomes extremely powerful.  With some additional coding, you could fairly easily create something that would work on any page '''automatically''' — without you having to type it on every single story page on the wiki.   


And, indeed, most of the value of parser functions is not in their use on an individual page.  Rather, they are the building blocks for coding templates that automatically find, manipulate, and most importantly '''link to''' information on ''any'' page.
And, indeed, most of the value of parser functions is not in their use on an individual page.  Rather, they are the building blocks for coding templates that automatically find, manipulate, and most importantly '''link to''' information on ''any'' page.
====More info on parser functions====
===More info on magic words===
If you want to explore the world of template coding with parser functions, there are a few pages you'll want to look at.   
If you want to explore the world of template coding with magic words such as parser functions, there are a few pages you'll want to look at.   


*[[mw:Help:Extension:ParserFunctions]]
*[[mw:Help:Extension:ParserFunctions]]

Revision as of 17:42, 17 April 2010

Tardis:Help

This page is a tutorial for learning to work with the essential rules of wiki-formatted text, or "wikitext". Wikitext is designed to be as simple as possible so that an article may be quickly typed and styled without having to take a break to type out long HTML codes. The goal is to make it as easy as possible to channel your thoughts into writing the perfect article (or even a not-so-perfect one).

Text formatting

Creating italicized or bold text is the simplest rule — simply use the apostrophe character in groups of two or three to create the style. (Be sure to use the "straight" apostrophe and not the curved "smart quote" characters used in some text editors and word processors!)

What you type What you see
''italicized text'' italicized text
'''bold text''' bold text
'''''italicized and bold text''''' italicized and bold text

To create a tabbed list or a block of text using a monospace font, start the line with a space. (Be sure not to make the line too long, or it will stretch the page horizontally!) Text can also be indented in blockquotes using the colon character.

What you type What you see

Preformatted text

Preformatted text
: Indented text
Indented text

Lists

Both unordered and numbered lists are simple to create as well: simply use the asterisk or hash characters at the beginning of a line to create the entry. To create nested lists, simply add an extra asterisk or hash to the front of the line. You can even mix and match the kinds of list in a single group!

What you type What you see
* Item One
* Item Two
  • Item One
  • Item Two
# Item One
# Item Two
  1. Item One
  2. Item Two
* Item One
** Item Two
  • Item One
    • Item Two
* Item One
*# Item Two
  • Item One
    1. Item Two
; term : definition
term
definition

Links and URLs

In a wiki, it's important to help build the web by creating links to other articles in every appropriate context. Use the following techniques to create "free links" to other Tardis Index File articles:

What you type What you see
[[TARDIS Index File]] TARDIS Index File
[[SS Bernice|SS ''Bernice'']] SS Bernice
[[This article doesn't exist]] This article doesn't exist
[[Tardis:Policies and Guidelines]] Tardis:Policies and Guidelines
[[Tardis:Policies and Guidelines|Policies and Guidelines]] Policies and Guidelines

You can also make external links to other websites using the following formatting rules:

What you type What you see
[[Wikipedia:Doctor Who]] Wikipedia:Doctor Who
[[Wikipedia:Doctor Who|]] Doctor Who
http://tardis.wikicities.com/ http://tardis.wikicities.com/
[http://tardis.wikicities.com/] [1]
[http://tardis.wikicities.com/ TARDIS Index File] TARDIS Index File

The "pipe trick"

One of the most helpful shortcuts one can learn in linking to articles is the so-called "pipe trick". By placing a pipe (|) after certain strings of text, one can eliminate the need to type huge amounts of replacement text. For example, if the name of an episode of Doctor Who is shared with a person, place or thing in the DWU, then it will be "disambiguated" with the parenthetical "(TV story)". Castrovalva refers to the city, whereas Castrovalva (TV story) links to the page about the episode. Generally, when writing a sentence about the TV story, one doesn't want "(TV story)" to appear in the body of text. To get rid of it, one must enter some replacement text separated by the full article name by a pipe (|}. The long way of doing that is:

[[Castrovalva (TV story)|Castrovalva]]

This is cumbersome, however, and there's a fair chance one might make a typing error somewhere along the way. Thus the easier way to proceed is:

[[Castrovalva (TV story)|]]

The pipe trick can also be used to get rid of namespace that precedes an article name. If you're on a talk page and you wish to refer to another user's name, you might type:

[[User:ILoveDaleksWhenTheyCry|ILoveDaleksWhenTheyCry]]

but that's a lot of work. Instead, just type:

[[User:ILoveDaleksWhenTheyCry|]]

Similarly, you might want to refer to an article outside mainspace. For instance, maybe you're arguing a stylistic point on a talk page, and you want to refer to Tardis:Manual of style. By typing:

[[Tardis:Manual of style|]]

you end up with just Manual of style.

And then there are cases when you have a link that has both a namespace and a disambiguating parenthetical. The pipe trick can take care of this, too. This frequently happens when linking to a wikipedia article. You could type:

[[wikipedia:Life on Mars (TV series)|Life on Mars]]

but why do that when

[[wikipedia:Life on Mars (TV series)|]]

also gives you Life on Mars.

The "slash trick"

There are some pages here which have a number of subpages. A subpage is a page that branches off of the page one is currently viewing. If this page had a subpage about slash tricks, it would be in the format of Help:Wiki markup/Slash trick. This syntax, however, is how one would link to the subpage from any other page on the wiki. On this page only the same link could be generated by typing

[[/Slash trick]]

When entered on this page, the preceding slash stands in for Help:Wiki markup. However, the result of typing in [[/Slash trick]] is the rather ugly /Slash trick, that includes the preceding slash. If one wanted to create a link that appeared on this page as just Slash trick, one could type:

[[/Slash trick|Slash trick]]

However, this can be simplified even further by typing:

[[/Slash trick/]]

This eliminates the preceding slash.

When you might not want to apply the slash trick

Generally, getting rid of preceding slashes is a great idea. But there are occasionally times when the preceding slash might need to be retained. A good example is Forum:Doctor Who television discontinuity and plot holes where the preceding slashes emphasize to the reader that a subpage was being linked to, rather than a page in the main article space with the same name.

A suggested guideline is that if the subpage has the same name as a proper article in mainspace, retain the slash for clarity. Thus /The Chase versus The Chase.

Interwiki link

There are times when one might wish to link to another wikia. For example, if one wanted to talk about Michelle Ryan's character on The Bionic Woman, one could link to the article on The Bionic Wiki, instead of relying on Wikipedia. This can be achieved by the following syntax:

[[w:c:nameofwiki:articlename|articlename]]
or, for this specific case,
[[w:c:bionic:Jaime Sommers (2007)|Jaime Sommers]]

Note that the pipe trick discussed above won't work as well on interwiki links because there are too many preceding colons. A pipe trick does this to an interwiki link: c:bionic:Jaime Sommers, which is close, but not really close enough. Thus, to make a "clean" link to an article on another link, one has to type out the whole thing, with replacement text, as shown immediately above.

How to figure out the name of a wiki

The real trick in performing interwiki links is knowing what is the true name of the wiki to which one is linking. For instance, we call ourselves "TARDIS Index File Wiki", but our true name is "tardis". Links to our article about Matt Smith from other wikias would be:

[[w:c:tardis:Matt Smith|Matt Smith]]

The key to finding the true name is to look at the URL address in one's browser window. The name is almost always the word which precedes the word "wikia". The URL to the Doctor Who page at Wikisimpsons is http://simpsons.wikia.com/wiki/Doctor_Who. This is the usual format for a wikia wiki. Thus: w:c:simpsons:Doctor Who is how you link to that page from within an article here at our wiki. Again, to clean it up a bit, you might type something like [[w:c:simpsons:Doctor Who|Doctor Who on ''The Simpsons'']]. This syntax will work in most cases. For instance, it works for linkage to all of our sister sites, thus:

Unfortunately, this isn't completely universal. Depending on the wiki's relationship to the wikia family of wikis, it might not be so straightforward. A prime example is Memory Alpha, the main Star Trek Wiki. The actual URL of its Doctor Who page is: http://memory-alpha.org/en/wiki/Doctor_Who. This is immediately confusing, because there's no reference to wikia at all in the URL. However, linkage to this page can still be achieved within an article here at this wiki. It is accomplished by w:c:memoryalpha:Doctor Who. In cases where the wiki URLs don't have the "wikia.com", you will have to search through that wiki's help files to find an article that tells you how to perform an interwiki link. Or you might have to ask an admin there for help. You can also try consulting the Interwiki link page at Wikia Central.

Even easier linking to "big" wikis

Some bigger wikis are even easier to link to. For some wikis, linkage is exactly like Wikipedia linkage.

To test whether the wiki is big enough to have its own prefix, enter wikiname:articlename in our search box on the top left of this page. If it takes you to the appropriate page, then you can use that syntax in a link. If it just creates a search error, then you have to use the w:c:wikiname:articlename syntax.

Beware the false blue link

Note that interwiki linking, whether by using a special prefix like [[wikipedia:articlename]] or the standard [[w:c:wikiname:articlename]] syntax, always produces a blue link. You must, therefore, go back and click the link you've made to ensure that it actually links properly. Just to illustrate, here are some obviously ridiculous page names that nevertheless appear to be valid links:

Sections

The usual way

If an article is long enough, you can divide the page into different sections. The TARDIS Index File will automatically generate a table of contents based on the content for all articles with more than three sections.

You can also create a horizontal divider by using four dashes in a row.

What you type What you see
== Header Two == Header Two
=== Header Three === Header Three
==== Header Four ==== Header Four
----

Another approach to headers

The above method doesn't just generate a header. It also automatically creates a little edit link beside the header, allowing the user to edit just that section. But there are times when one may wish to have a sectional header that isn't editable. This is particularly true in templates which generate a lot of text that need to be sectionalized for greater understanding. To achieve section heads which don't produce an edit link, use the following simple code:

<hx>Header</hx>, where x stands for the number of equal signs (=) you want.

For example, 

<h3>Header</h3>

is the edit-link-less version of

===Header===

Images and other media

See: Help: Image markup

Tables

See: Help: Table markup


Mathematical formulae

See: Help: Math markup

Templates

A template is a pre-defined bit of coding that places the same text across multiple pages. It can be as simple as a little system message, such as Template:Current to a fairly complicated bit of coding that automatically calculates dates based upon the name of an article, like Template:Timeline.

One of the types of template you will most come into contact with here on tardis is the "infobox" template. These save you a great deal of repetitive typing of similar information, such as is found on television story or novel pages. Just go to the Templates page and scan down the list for the ones you need. Put {{template}} in your edit, replacing "template" with the name of the specific one you are using, such "Infobox CD". For infoboxes, you will need to fill in the variables accepted by the template, such as director, writer, or broadcast date.

The actual writing of templates is a complicated subject, beyond the scope of this article.

See also: Help:Template

Magic words

Beyond the templates that we have created are templates that are inherent in the MediaWiki software. These are not fully listed anywhere on this wiki, and do not appear in Category:Templates. A good place to start one's understanding of these type of templates is at Wikipedia:Help:Magic words.

They are called "magic" because they do things with one simple word that conceals rather a lot of complicated coding. Most editors of wikis, even those very experienced with template coding, don't really understand the underlying code that makes them work. Hence, as was once remarked in Battlefield, any sufficiently advanced technology is indistinguishable from magic.

Variables

Some of the simplest magic words have to do with detecting dates and other numbers. Because they return values which are not constant, this type of magic word is called a variable.

Code Effect
{{CURRENTMONTH}} 11
{{CURRENTMONTHNAME}} November
{{CURRENTMONTHNAMEGEN}} November
{{CURRENTDAY}} 12
{{CURRENTDAYNAME}} Tuesday
{{CURRENTYEAR}} 2024
{{CURRENTTIME}} 20:01
{{NUMBEROFARTICLES}} (number of articles in main namespace containing a link and not a redirect) 114,029

These are not variables in the sense of being "user definable". The user has no control over the content of the variable. The term variable has another wiki code meaning, particularly in templates. If one wishes to elicit a response from a user in a template, such as by requesting the input of a director's name on an infobox, one would use a variable such as {{{Director}}}. Note that in wiki syntax, a user-defined variable is indicated by three curly braces {{{variable}}}, not two.

Behavior switches

Another type of magic word is the behavior switch. These are indicated by the format __BEHAVIORSWITCHNAME__. Note the syntax requires a one-word name in all caps enclosed in two underscores. No other variation will work. Here are some of the most common ones:

  • __NOTOC__ (can appear anywhere in the wikitext; suppresses the table of contents)
  • __FORCETOC__ (can appear anywhere in the wikitext; makes a table of contents appear in its normal position above the first header)
  • __TOC__ (places a table of contents at the word's position)
  • __NOEDITSECTION__ (hides the section edit links beside headings)
  • __NEWSECTIONLINK__ (adds a "+" link for adding a new section on a non-"Talk" page)
  • __NONEWSECTIONLINK__ (removes the "+" link on "Talk" pages)
  • __NOGALLERY__ (on a category page, replaces thumbnails with normal links)
  • __HIDDENCAT__ (on a category page, makes it a hidden category)
  • __INDEX__ (tells search engines to index the page)
  • __NOINDEX__ (tells search engines not to index the page)
DEFAULTSORT and DISPLAYTITLE

Additionally, there are two very important behavior switches that impact variables. They might be thought of as "variable behavior switches".

  • {{DISPLAYTITLE:title}} (changes the displayed form of the page title)
  • {{DEFAULTSORT:sortkey}} (sets a default category sort key)


DISPLAYTITLE could be used more often at this wiki than it is. For instance, the title of articles at the top of the page could be made to be italicized in the case of book titles, for instance. However, there is no consensus on this, as yet. One article that does use DISPLAYTITLE is IPod, in order to make it properly render as having a lower-case "i" a the beginning of the word iPod. DISPLAYTITLE is a rather finicky bit of code, however, and will only accept certain changes to the title. For instance, it happily accepts iPod, but balks ad iPOd.

DEFAULTSORT is a particularly important magic word to understand, as it should be placed on every page you create, if the title of that page is a person's name, or an article that begins with an article, such as "a", "an" or "the".

Thus, the articles Steven Moffat and The Girl in the Fireplace, should have this notation at the bottom:

{{DEFAULTSORT:Moffat, Steven}}
{{DEFAULTSORT:Girl in the Fireplace, The}}

This will automatically sort the article alphabetically in whatever categories it is placed into.

Parser functions

Parser functions are magic words that get the wiki software to perform an action upon a string (that is a set of letters, numbers and/or symbols) in order to return a result. Explaining all their possible functions is well beyond this scope of this help page.

However, there are two major type of parser function, conditional and non-conditional. A condtional function is one that results in an action based upon some sort of if/then/else logic. Here's a list of conditional functions with a very basic explanation of each:

  • {{#expr: expression }} (evaluates the given expression; see wikipedia:Help:Calculation) While not strictly conditional, it's often nested within a conditional statement so as to answer the question, "If the result of this calculation is something, then take this action; otherwise, do this other thing."
  • {{#if: test string | value if non-empty | value if empty }} (selects one of two values based on whether the test string is empty)
  • {{#ifeq: string 1 | string 2 | value if equal | value if unequal }} (selects one of two values based on whether the test strings are equal – numerically if applicable)
  • {{#iferror: test string | value if error | value if correct }} (selects value based on whether the test string generates a parser error)
  • {{#ifexpr: expression | value if true | value if false }} (selects value based on evaluation of expression)
  • {{#ifexist: page title | value if exists | value if doesn't exist }} (selects value depending on whether a page title exists)
  • {{#switch: test | case1 = value for case 1 | ... | default }} (provides alternatives based on the value of the test string)

These are not very useful within the space of a normal article. However, they are used extensively in templates. The utility of #ifeq should be readily apparent. For example, here's a silly little example which puts together variables and conditional expressions into a single statement. If we wanted to put a code on every episode page until it found Doctor Who (1996) and put up a disambiguation note this is what we'd do:

{{#ifeq: | {{PAGENAME}} | Doctor Who (1996) | :''For other uses of the name ''Doctor Who'', please see [[Doctor Who (disambiguation) |}}
  1. #ifeq: says "look at the first two things and see if they're equal"
  2. "{{PAGENAME}}" returns the value of the current page
  3. "Doctor Who (1996)" is the value we're trying to match
  4. ":''For other uses . . . " is the event we want to happen if the first two things are equal
  5. "|}}" says "if the first two things are unequal do nothing". If we wanted the code to take a positive action on inequality, we'd type something between the pipe and the curly brackets. So, we could write: {{#ifeq:|{{PAGENAME}}|Doctor Who (1996)|:''For other uses of the name ''Doctor Who'', please see [[Doctor Who (disambiguation)|This is not Doctor Who (1996)}} But that would be rather silly.

Parser functions have exactly the same syntax as conditional functions, but they don't actually depend on if/then logic to produce the result. No attempt will be made here to even list all the possible parser and string functions. But we will examine one example: #titleparts.

This function separates a pagetitle into segments based on slashes, then returns some of those segments as output.

{{#titleparts: pagename | number of segments to return | first segment to return }}

If the number of segments parameter is not specified, it defaults to "0", which returns all the segments. If the first segment parameter is not specified or is "0", it defaults to "1".

Let's imagine that we had made our talk page for An Unearthly Child a little more complicated than it actually is. Consider what would happen if we gave each individual episode a subpage of its own. This, then, is how we could use #titleparts to manipulate the subpage titles:

{{#titleparts: Talk:An Unearthly Child/Episodes/Cave of Skulls}}Talk:An Unearthly Child/Episodes/Cave of Skulls
{{#titleparts: Talk:An Unearthly Child/Episodes/Cave of Skulls | 1 }}Talk:An Unearthly Child
{{#titleparts: Talk:An Unearthly Child/Episodes/Cave of Skulls | 2 }}Talk:An Unearthly Child/Episodes
{{#titleparts: Talk:An Unearthly Child/Episodes/Cave of Skulls | 2 | 2 }}Episodes/Cave of Skulls

Perhaps most usefully, we could use a negative number to actually find the name of the episode, and link to it.

{{#titleparts: Talk:An Unearthly Child/Episodes/Cave of Skulls | | -1 }} Cave of Skulls

Now, you might be thinking, "How does that save any time whatsoever? I could just type [[Cave of Skulls]] and be done with it." And yes, you could. But within a template this becomes extremely powerful. With some additional coding, you could fairly easily create something that would work on any page automatically — without you having to type it on every single story page on the wiki.

And, indeed, most of the value of parser functions is not in their use on an individual page. Rather, they are the building blocks for coding templates that automatically find, manipulate, and most importantly link to information on any page.

More info on magic words

If you want to explore the world of template coding with magic words such as parser functions, there are a few pages you'll want to look at.

Suppressing markup

It's also possible to tell MediaWiki to ignore any of the above rules using a simple tag:

What you type What you see
<nowiki>'''text here'''</nowiki> '''text here'''