JA:Wiki syntax

From OpenStreetMap Wiki
Jump to navigation Jump to search

Editing a wiki-page is in most cases straightforward, just enter your text. Anyway you have to consider some conventions and you need to know how to format the text. The basics of these convention and some of the most frequent used formatting (wiki-markup) will be explained in this article.

Important
Use the button "Show Preview" to see how your text and formatting will look like.
Use this button as often as needed before you "Save Page".
Make small edits, a few lines/paragraphs, one list, table or new section at a time.
In case something went wrong and you saved the changes, you can revert these changes in the version history of the page. Use this rarely but when necessary.
You may use the sandbox of the OSM-wiki to experiment with markup you are not yet familiar with.


More comprehensive resources

  • For a short overview of most frequent wiki editing syntax (wiki markup) see Help:Editing on meta.wikimedia.org English
  • Another overview of frequently used wiki syntax (wiki markup) can be found in the text examples on meta.wikimedia.org English
  • For a more comprehensive list of wiki markup see Help:Wiki_markup on Wikipedia English, German (Deutsch)
  • For a complete list of wiki help topics including wiki edits see Help:Contents on MediaWiki and its followup pages. English


Editing conventions

Continuous text
  • You may enter text just as it is. This will result in continuous text which will wrap around as needed.
  • A new line in the wiki-source does not break the text into paragraphs.
  • To separate text into paragraphs you need to include one empty line between each part.

Example:

Text displays as you type it and wraps around even with a newline embedded.

Wiki source:

Text displays as you
type it and wraps
around even with a
newline embedded.

Formatting text
  • Surrounding text with two apostrophes (') will display this text in italic.
  • Surrounding text with three apostrophes (') will display this text in bold.
  • Surrounding text with five apostrophes (') will display this text in bold italic.
  • Using one apostrophe (') displays just this apostrophe.

Example:

Highlight 'your' text in italic, bold or bold-italic

Wiki source:

Highlight 'your' text in ''italic'', '''bold''' or '''''bold-italic'''''

Special formatting
  • To avoid text wrapping, use a non-breaking space   like in Nr. 1 Hit.
  • A pair of '<nowiki>' and '</nowiki>' disables the wiki-syntax in the enclosed text.
  • Surround your text with '<!-- ', ' -->' and the enclosed text will not display on the wiki-page (a comment).

Example:

Nr. 1 Hit


Use as needed.

Wiki source:

'''Nr.&nbsp;1&nbsp;Hit'''

Use <!--comments--> as needed.

The first or the first few character(s) of a line determine, what kind of text the line is.
  • A line with a space ( ) as first character is an unformatted line, which will not wrap around.
    This is handy for a list of short items and useful, when showing a section of source code.
  • A star (*), a number sign (#), a semicolon (;) or a colon (:) as first character indicate a list-item.
    Using more than one of these characters allow nested lists.
  • A line beginning with '{|' or '|-' or '|+' or '|' or '!' or '|}' belongs to a table.
  • A flight of '=' at the start and end of a line indicates a section header.
  • A line where the first character is a letter or a digit is default text and will wrap around as needed.
  • A line that starts with one or two square brackets ([), a link, or starts with two curly braces ({{), a template, is treated as default text, which will wrap around as needed. Links and templates are embedded in text and have no special meaning if they happen to start a line.
  • A line starting with so far unmentioned characters most likely will be treated as default text.

Example:

Space as first character 
  1. Numbered item
  • List item
    • Nested list
Indentation
Definition term
Definition text


Main Page

key=value


@ At sign
§ paragraph

Wiki source:


   Space as first character

# Numbered item
* List item
** Nested list
 : Indentation

 ; Definition term
 : Definition text

[[Main Page]]
{{tag|key|value|pair}}


@ At sign
§ paragraph

Headers

A section starts with a header consisting of a line beginning and ending with two or more consecutive equal signs (=). The number of equal signs indicates the nesting level of sections.

When using several sections a table of contents is created just before the first header. This article as an example has more than five sections and consequently a table of contents.

If you want the table of contents to appear in a different place, you may use __TOC__ to define the place where the table of contents is displayed. You may use __NOTOC__ anywhere in the document, if you want the table of contents not to display at all.

Example:

Header 2

Header 3

Header 4

Wiki source:

=== Header 2 ===
...
==== Header 3 ====
...
===== Header 4 =====

Lists

To create a list is pretty simple, just write a star (*) as first character on one or more consecutive line(s). This will display as a bullet list.

If you use number signs (#) instead of stars (*) you create an ordered list. This will display as a list with numbers instead of bullets.

You may create nested lists by increasing the number of stars / number signs. Nested lists display as lists with different levels of indentation. When nesting lists you may mix bullet lists and numbered lists on each level.

Example:

  • A list with
    1. two levels
    2. and numbers
  • first level again

Wiki source:

* A list with
*# two levels
*# and numbers
* first level again

You can create a definition list by using a semicolon (;) as first character of a line, write your definition term, write one colon (:) and finally your definition text. This will display as two lines, first the definition term in bold, second the definition text with indentation.

You may separate definition term and definition text onto two lines for better readability in the wiki source. If you want to do so, use a colon (:) as first character of the second line with the definition text.

Although not intended you may use a colon (:) alone without a line for a definition term, which will display as an indentation. Using multiple lines with the colon as first character, you can create a list without any marking. This is allowed to support multiple paragraphs for a definition text. As with other types of lists you may use multiple colons to increase the indentation level.

Examples:

Definition term
definition text
second paragraph

 

No definition term
only indented
two levels

Wiki source:

 ; Definition term
 : definition text
 : second paragraph


 : No definition term
 :: only indented
 :: two levels

Note: Each line marked with one of the above characters (*, #, ; or :) as the first character is one list-item. A newline in wiki-source will end a list-item. If you happen to need a new line displayed within a list-item, you may use <br /> inline in the wiki-source which builds the list-item.

Example:

  • List-item will end

at a newline

Wiki source:

* List-item will end
at a newline

Links

Links within the same wiki are pretty simple. Just surround the article-name with double square brackets [[wiki-link]]. You might add a different text for the link by adding a pipe symbol (|) and the text that should appear as the link-text. [[wiki-link | link-text]] If you want a special language version of an wiki-article prefix the article-name with the two-letter language-code and a colon (:). This results in a link like [[DE:wiki-link]] for a german version of a wiki article.

Example:

Wiki_Help
Wiki Help (english)
Wiki Hilfe (deutsch)

Wiki source:

[[Wiki_Help]]
[[Wiki_Help | Wiki Help (english)]]
[[DE:Wiki_Help | Wiki Hilfe (deutsch)]]

If you want a link to a wikipedia-article, then prefix the article-name with "wikipedia:" This will give [[wikipedia:article-name]] as link. This will result in a link to the English Wikipedia as the default Wikipedia. If you need to link to another language Wikipedia note the language code with an appended colon immediate after "wikipedia:" and before the article name. A link to the German Wikipedia thus looks like [[wikipedia:de:article-name]].

Example:

wikipedia:Main Page
wikipedia:de:Wikipedia:Hauptseite

Wiki source:

[[wikipedia:Main Page]]
[[wikipedia:de:Wikipedia:Hauptseite]]

External links are quite easy as well. Just type the URL like ''https://help.openstreetmap.org'' and it will display as a clickable link with the URL as link-text. If you want a very short link, surround the URL with single square brackets [external-link] which displays as a numbered link like [7] . This is really short but in most cases not very meaningful. It is better practice to give a hint what this link points to. To do so, surround the URL, a space (“ ”) and the link-text with single square brackets [external-link link-text] which displays as the link-text.

Please note, that (different from wiki-links) a space character(“ ”) separates the link from the link-text. All external links are marked with a symbol which is generated through the used stylesheet.

If a target webpage is accessible via HTTP and HTTPS (secure), you could omit the protocol and colon in the link (only if you use the explicit link syntax with “[]”). In the resulting wiki page the link will inherit the protocol from the current wiki page. This is called a protocol-relative link and helps readers to keep their preferred protocol while browsing.

Example:

https://help.openstreetmap.org

A short link [1]

OSM help site

OSM website


Wiki source:

https://help.openstreetmap.org
A short link
[https://help.openstreetmap.org]
[https://help.openstreetmap.org OSM help site]
[//www.openstreetmap.org OSM website]

Tables

A table is a two-dimensional grid consisting of rows and columns which allows to arrange information according to two criteria, one in the rows and one in the columns.

A basic table needs the following parts:

  • A line with the first two characters '{|' indicating the begin of a table.
  • An optional line with the first two characters '|+' for the caption of the table.
  • One or more table rows, each a line with the first two characters '|-' and usually no other content
  • After each table row one or more lines with table cells and their text/content. A table cell has as first character a pipe symbol (|) and the second character ist neither plus (+) nor minus (-) for these two are reserved for caption and table row respectively.
  • A line with the first two characters '|}' indicating the end of a table.

It is good practise and increases readability to use a space as second/third character, thus avoiding any ambiguity.

Example:

table caption
This is a
2 x 2 table

Wiki source:

{| align="center"
|+ table caption
|- align="center"
| This
| is a
|- align="center"
| 2 x 2
| table
|}


Tables have an important difference to lists. Lists are restricted to one line in the wiki-source. Table cells can have almost everything that you can express with wiki markup. This includes paragraphs, lists, images or other media and even tables in a table cell are possible although not encouraged.

There are a lot of tricky things you might do with tables. If you want further information try Wikipedia's help on tables. English, German (Deutsch)

Example:

This is a table
within
another table

Wiki source:

{| border="1"
|- align="center"
| This is a table
{| align="center"
|- align="center"
| within
|} another table
|}

Templates

Templates are textual macros. They are articles in a special namespace (Template:) Templates are used to have identical text or text structure within several articles. Templates are expanded and included on the fly when opening an article. (You might suppress this if needed.) Templates are called by surrounding the template name with double curly braces {{template-name}}.

Templates can have parameters. Parameters are separated by pipe symbols {{template-name | parameter}}. Parameters can be positional as in {{template-name | param-1 | | param-3 }} where you need an empty parameter if you want to omit a positional parameter. Parameters can be named, in which case you denote the named parameters as key-value pairs {{template-name | param-X=value-X | param-F = value-F}}. You may use spaces for readability as you like. Parameters can have a default value defined inside the template. This value is used if you do not specify a value for a parameter.

There is a wide range how templates are used. Templates can be a simple text-inclusion allowing identical text and formatting over several pages. Templates can create infoboxes and alike with parameters and sophisticated formatting. You might refer to the list of most linked templates in the OSM-wiki to find widely used templates.

Templates used within your edit are listed at the bottom of the edit page. You might use the links to see what's that all about.

Warning: Creating new or modifying existing templates is not for the beginner.
Anyway a beginner should know what these strange double curly braces are used for.

Example:

Icon-template for:

ノード nodes
ウェイ ways
閉じたウェイ closed ways
エリア areas
リレーション relations


The Tag-template is in

key=value

heavy use in the wiki


Create links for
.Keep Right
(Cologne Center)


Wiki source:

Icon-template for:
  {{Icon|node}} nodes
  {{Icon|way}} ways
  {{Icon|closedway}} ...
  {{Icon|area}} areas
  {{Icon|relation}} ...


The Tag-template is in
  {{Tag |key|value}}
heavy use in the wiki


Create links for
{{Keepright | lat=50.94 |
long=6.95 | zoom=16 }}
(Cologne Center)

See also

  • For general information about using this wiki refer to the OSM-page on Wiki Help (no special help for editing/markup). English German (Deutsch)
  • For an overview on using the wiki editor see the Wikipedia help page (no special help for markup). English German (Deutsch)