Help:Formatting: Difference between revisions

+ Short summary of templates and tables + Pre-formatted text and syntax highlighting. Now 99% complete
(Clarifying, rephrasing and extending + External links to more detailed help. About 98% done rewriting)
(+ Short summary of templates and tables + Pre-formatted text and syntax highlighting. Now 99% complete)
Line 1: Line 1:
:''For help on tables and templates, see [[Help:Tables]] and [[Help:Templates]].''
This page is about '''editing''' a wiki page.  We will go through the general disposition of articles on this wiki, basic wiki editing, when and how to add links to other wiki pages and articles as well as a few other things.  The more advanced editing are will not be dealt with on this page though.
This page is about '''editing''' a wiki page.  We will go through the general disposition of articles on this wiki, basic wiki editing, when and how to add links to other wiki pages and articles as well as a few other things.  The more advanced editing are will not be dealt with on this page though.


Line 118: Line 117:
=== A few useful HTML tags ===
=== A few useful HTML tags ===
Yes you ''can'' use HTML tags in a wiki page.  Usually it is not needed though, as you in the most cases are better helped by wiki markup, but in a few cases they can be very helpful.
Yes you ''can'' use HTML tags in a wiki page.  Usually it is not needed though, as you in the most cases are better helped by wiki markup, but in a few cases they can be very helpful.
One of the properties of the HTML tags is that you can use HTML attributes and with them the style attribute which gives access to the whole cascading style sheet toolbox.


{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
Line 138: Line 139:
  <nowiki><s>Some text</s></nowiki>
  <nowiki><s>Some text</s></nowiki>
| <s>Some text</s>
| <s>Some text</s>
|-
| Using HTML attributes.
|
<nowiki><big style="colour: red;">'''Error !!!'''</big></nowiki>
| <big style="color: red;">'''Error !!!'''</big>
|-
|-
| Comments can be added using HTML comment tags on each side.
| Comments can be added using HTML comment tags on each side.
Line 145: Line 151:
|}
|}


Apart from the HTML tags there is also some wiki tags, a few of them more useful than the others.
Apart from the HTML tags there is also some wiki tags, a few of them more useful than the others.  These tags can not use the HTML attributes.


{| class="wikitable" width="100%"
{| class="wikitable" width="100%"
Line 246: Line 252:
::Indentation  
::Indentation  
|}
|}


== Headings and subheadings ==
== Headings and subheadings ==
Line 316: Line 321:
| Pipe links are wiki links with a vertical stroke or pipe ('''<nowiki>|</nowiki>''') separating the page to be linked to from an alternative link text
| Pipe links are wiki links with a vertical stroke or pipe ('''<nowiki>|</nowiki>''') separating the page to be linked to from an alternative link text
|
|
  <nowiki>A [[Help:Templates|template]] can be very practical.</nowiki>
  <pre style="white-space: pre-wrap;">A [[Help:Templates|template]] can be very practical.</pre>
| A [[Help:Templates|template]] can be very practical.
| A [[Help:Templates|template]] can be very practical.
|-
|-
| You can link to a section of an article by adding a hash ('''#''') and the section heading after the name or the article.
| You can link to a section of an article by adding a hash ('''#''') and the section heading after the name or the article.
|
|
  <nowiki>Tables can be [[Help:Tables#Sortable tables|sortable]].</nowiki>
  <pre style="white-space: pre-wrap;">Tables can be [[Help:Tables#Sortable tables|sortable]].</pre>
| Tables can be [[Help:Tables#Sortable tables|sortable]].
| Tables can be [[Help:Tables#Sortable tables|sortable]].
|}
|}
Line 344: Line 349:
| External link with label.  A blank space ( ) separates the URL from the label.
| External link with label.  A blank space ( ) separates the URL from the label.
|
|
  <nowiki>[http://www.mediawiki.org/wiki/Help:Links MediaWiki link help]</nowiki>
  <pre style="white-space: pre-wrap;">[http://www.mediawiki.org/wiki/Help:Links MediaWiki link help]</pre>
| [http://www.mediawiki.org/wiki/Help:Links MediaWiki link help]
| [http://www.mediawiki.org/wiki/Help:Links MediaWiki link help]
|}
|}
Line 354: Line 359:


Permalinks can be found either under the "Toolbox" drop-down list on the left menu or in the revision history in the "View history" tab.  To get the link to a diff you will have to show the diff and copy the URL in your browsers address field.
Permalinks can be found either under the "Toolbox" drop-down list on the left menu or in the revision history in the "View history" tab.  To get the link to a diff you will have to show the diff and copy the URL in your browsers address field.
== Templates ==
{{main article|Help:Templates}}
''Templates'' is a very handy feature of the MediaWiki wiki markup.  Using templates you can easily add complex things like the messageboxes, infoboxes and navboxes, but also a lot, lot more.
A few useful templates are shown below:
{| class="wikitable" width="100%"
! Description
! width="30%" | What you type
! width="30%" | What you get
|-
| {{tl|dead link}} is used when marking dead links.
|
<pre style="white-space: pre-wrap;">{{dead link|{{CURRENTYEAR}}-{{CURRENTMONTH}}}}</pre>
| {{dead link|{{CURRENTYEAR}}-{{CURRENTMONTH}}}}
|-
| {{tl|clarify}} can be used to mark ambiguities and diffuse statements.
|
<pre style="white-space: pre-wrap;">{{clarify|What's a magneto test|{{CURRENTMONTHABBREV}} {{CURRENTYEAR}}}}</pre>
| {{clarify|What's a magneto test|{{CURRENTMONTHABBREV}} {{CURRENTYEAR}}}}
|-
| {{tl|tl}} can be used to make nice looking links to templates
|
<nowiki>{{tl|informative template}}</nowiki>
| {{tl|informative template}}
|}
== Tables ==
{{main article|Help:Tables}}
''Tables'' are very useful for, well, tabulating data, but also for layout purposes.
{| class="wikitable" width="100%"
! Description
! width="30%" | What you type
! width="30%" | What you get
|-
| A small and simple table sample.
|
<nowiki>{| class="wikitable"
! Cell one !! Cell two
|-
| Cell three || Cell four
|}</nowiki>
|
{| class="wikitable"
! Cell one !! Cell two
|-
| Cell three || Cell four
|}
|}
== Pre-formatted text ==
There is many different ways to do monospaced pre-formatted text.
=== Pre-formatted running text ===
{| class="wikitable" width="100%"
! Description
! width="30%" | What you type
! width="30%" | What you get
|-
| Using <nowiki><code></nowiki> HTML tags.
|
<pre style="white-space: pre-wrap;">Here is a <code>'''Class()'''</code>.</pre>
| Here is a <code>'''Class()'''</code>.
|-
| Using <nowiki><tt></nowiki> HTML tags.
|
<pre style="white-space: pre-wrap;">Here is a <tt>''variable''</tt>.</pre>
| Here is a <tt>''variable''</tt>.
|}
=== Pre-formatted blocks ===
Apart from using <nowiki><tt></nowiki> and <nowiki><code></nowiki> on entire blocks of text one one can use the below methods.
{| class="wikitable" width="100%"
! Description
! width="30%" | What you type
! width="30%" | What you get
|-
| The simplest way is with a leading blank space on each line.
|
<nowiki> You '''''can''''' use '''wiki markup'''
using this method.</nowiki>
|
You '''''can''''' use '''wiki markup'''
using this method.
|-
| Using <nowiki><nowiki></nowiki> tags with a leading blank space.
|<pre> <nowiki><nowiki>Here is some text.
And some more.</nowiki></nowiki></pre>
|
<nowiki>Here is some text.
And some more.</nowiki>
|-
| Using <nowiki><pre></nowiki> tags.
|
<nowiki><pre>Some text.
Some more text.</pre></nowiki>
| <pre>Some text.
Some more text.</pre>
|}
=== Wrapping in pre-formatted blocks ===
None of the above mentioned methods for pre-formatted text block wraps.  A line that is too long to fit the screen width would continue past the screen edge instead of wrapping around to continue on the following line.  A work around to this is to use the <nowiki><pre></nowiki> tag together with a style attribute to wrap the text.
{| class="wikitable" width="100%"
! Description
! width="30%" | What you type
! width="30%" | What you get
|-
| Using <nowiki>&lt;pre style="white-space: pre-wrap;"&gt;</nowiki> to wrap the text.
|
<nowiki><pre style="white-space: pre-wrap;">This is a very long...</pre></nowiki>
|<pre style="white-space: pre-wrap;">This is is a very long line of text that could continue past the screen edge.  I could have filled it with pure nonsense but I think I will instead just be lazy and copy what I got so far.  Sorry.  This is is a very long line of text that could continue past the screen edge.  I could have filled it with pure nonsense but I think I will instead just be lazy and copy what I got so far.  Sorry.</pre>
|}
{| class="wikitable"
! width="40%" | Description
! width="30%" | What you type
! What you get
|-
| Using only <nowiki>&lt;pre&gt;</nowiki>.
|
<nowiki><pre>This is a very long...</pre></nowiki>
|<pre>This is is a very long line of text that could continue past the screen edge.  I could have filled it with pure nonsense but I think I will instead just be lazy and copy what I got so far.  Sorry.  This is is a very long line of text that could continue past the screen edge.  I could have filled it with pure nonsense but I think I will instead just be lazy and copy what I got so far.  Sorry.</pre>
|}
== Syntax highlighting ==
''Syntax highlighting'' will source code more readable.  This wiki has support for many programming languages, including [[nasal]], XML and C++.  The source code to be highlighted is put between <nowiki><syntaxhighlight></nowiki> tags.  The tag can be given attributes some attributes to control how the code appears.
&lt;'''syntaxhighlight''' lang="" ''line start=""'' ''highlight=""'' ''enclose=""''&gt;&lt;/syntaxhighlight&gt;
All attributes but '''lang''' is optional.  '''start''' have to be used together with '''line'''.  Values need to be put inside quotation marks ('''"''').
;lang:  The language to be highlighted, for example '''xml''', '''nasal''' and '''cpp'''.
;line:  Use line numbering.
;start:  Used together with '''line''' if you want the line numbering to start somewhere else than one.
;highlight:  Used for highlighting a line.  Do note that lines are counted from one disregarding '''start'''.
;enclose
: Encloses the source code in a certain html tag.  Takes either '''pre''', '''div''' or '''none''', with '''pre''' being the default one.
: Using '''div''' will wrap lines that are too long to fit the screen width so they continue on the following line.
{| class="wikitable" width="100%"
! Description
! width="30%" | What you type
! width="30%" | What you get
|-
| Nasal highlighting.
|
<pre style="white-space: pre-wrap;"><syntaxhighlight lang="nasal" enclose="div">
fgcommand("profiler-start"); # default file name is fgfs.profile
// or with a custom filename
fgcommand("profiler-start", props.Node.new({"filename": "output.profile"}));
</syntaxhighlight>
</pre>
| <syntaxhighlight lang="nasal" enclose="div">
fgcommand("profiler-start"); # default file name is fgfs.profile
// or with a custom filename
fgcommand("profiler-start", props.Node.new({"filename": "output.profile"}));
</syntaxhighlight>
|-
| XML highlighting, here with line numbering arbitrarily starting from line 42.
|
<pre style="white-space: pre-wrap;"><syntaxhighlight lang="xml" line start="42" enclose="div">
<animation>
  <object-name>Object</object-name>
  <enable-hot type="bool">false</enable-hot>
</animation>
</syntaxhighlight>
</pre>
| <syntaxhighlight lang="xml" line start="42" enclose="div">
<animation>
  <object-name>Object</object-name>
  <enable-hot type="bool">false</enable-hot>
</animation>
</syntaxhighlight>
|-
| C++ highlighting, arbitrarily starting from 46, and highlighting 4th line in the example.
|
<pre style="white-space: pre-wrap;"><syntaxhighlight lang="cpp" line start="46" highlight="4" enclose="div">
globals->get_commands()->execute("profiler-start");
// or with filename
SGPropertyNode args;
args.setStringValue("filename", "output.profile");
globals->get_commands()->execute("profiler-start", &args);
</syntaxhighlight></pre>
|<syntaxhighlight lang="cpp" line start="46" highlight="4" enclose="div">
globals->get_commands()->execute("profiler-start");
// or with filename
SGPropertyNode args;
args.setStringValue("filename", "output.profile");
globals->get_commands()->execute("profiler-start", &args);
</syntaxhighlight>
|}


== Language links ==
== Language links ==
Line 371: Line 575:
| Another language version can also be linked to preceding colon ('''<nowiki>:</nowiki>''').
| Another language version can also be linked to preceding colon ('''<nowiki>:</nowiki>''').
|
|
  <nowiki>See also the [[:de:Help:Übersetzen|German page]].</nowiki>
  <pre style="white-space: pre-wrap;">See also the [[:de:Help:Übersetzen|German page]].</pre>
| See also the [[:de:Help:Übersetzen|German page]].
| See also the [[:de:Help:Übersetzen|German page]].
|}
|}
Line 403: Line 607:
| Links to categories can use a pipe ('''<nowiki>|</nowiki>''') as well.
| Links to categories can use a pipe ('''<nowiki>|</nowiki>''') as well.
|
|
  <nowiki>See the [[:Category:Help|help]] category.</nowiki>
  <pre style="white-space: pre-wrap;">See the [[:Category:Help|help]] category.</pre>
| See the [[:Category:Help|help]] category.
| See the [[:Category:Help|help]] category.
|}
|}
Line 426: Line 630:
* [http://www.mediawiki.org/wiki/Help:Links MW:Help:Links]
* [http://www.mediawiki.org/wiki/Help:Links MW:Help:Links]
* [http://www.mediawiki.org/wiki/Help:Images MW:Help:Images]
* [http://www.mediawiki.org/wiki/Help:Images MW:Help:Images]
* [http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi MW:Extension:SyntaxHighlight_GeSHi]


=== Wikimedia Meta-Wiki help pages ===
=== Wikimedia Meta-Wiki help pages ===