Jump to content

User:Liutinaa/sandbox

From Wikipedia, the free encyclopedia

Going in

[edit]

This session will cover:

  • What you need to know about Wiki markup (or Wikitext) to edit comfortably enough in most situations
    • Topics are broken out by task (e.g. formatting, linking, communicating with other editors) and include exercises
    • We will cover templates in greater depth during August's second Wikidata Working Hours session (Monday 17th).
  • Tips and tricks for making Wiki markup editing work for you

This session will be useful if:

  • You have mostly edited Wikipedia (or some other Wikimedia project) with the Visual Editor, and have limited experience with the text (source) editor
  • You find the source view of Wikimedia projects confusing or complicated
  • You are somewhat familiar with the content, but wish to revisit it or just want some practice
  • You're a Wiki markup master but you've stepped away for six years and would like a refresher

You will need:

Basics

[edit]

Wiki markup (or Wikitext) is one of many lightweight markup languages (LML) that prioritise human readability.

  • Wiki markup works across all MediaWiki-based platforms, including all Wikimedia projects and other wikis built on MediaWiki
  • Technically, Wikitext refers to text snippets or documents written in the Wiki markup language. But many use the terms interchangeably.
  • Other LMLs include Markdown and GitHub Flavored Markdown.
  • By comparison, HTML allows you to do more things but compromises on human readability.

Here is a table demonstrating how Wiki Markup compares to HTML (from Wiki#Basic syntax):

MediaWiki syntax (the "behind the scenes" code used to add formatting to text) Equivalent HTML (another type of "behind the scenes" code used to add formatting to text) Rendered output (seen onscreen by a regular web user)
"Take some more [[tea]]," the March Hare said to Alice, very earnestly.

"I've had '''nothing''' yet," Alice replied in an offended tone, "so I can't take more."

"You mean you can't take ''less''," said the Hatter. "It's very easy to take ''more'' than nothing."
<p>"Take some more <a href="/wiki/Tea" title="Tea">tea</a>," the March Hare said to Alice, very earnestly.</p>

<p>"I've had <b>nothing</b> yet," Alice replied in an offended tone, "so I can't take more."</p>

<p>"You mean you can't take <i>less</i>," said the Hatter. "It's very easy to take <i>more</i> than nothing."</p>
"Take some more tea," the March Hare said to Alice, very earnestly.

"I've had nothing yet," Alice replied in an offended tone, "so I can't take more."

"You mean you can't take less," said the Hatter. "It's very easy to take more than nothing."

As we begin, you may find it helpful to turn on syntax highlighting!

  • This feature colours your syntax to make it easier (and more fun!) to use Wikitext.
  • To enable it, toggle the button () that appears in the toolbar.
  • If you're curious about how this works, see: Extension:CodeMirror.

Formatting

[edit]

Characters

[edit]
  • Bold: Use three apostrophes(') on either side. '''foo'''
  • Italics: Use two apostrophes(') on either side. ''foo''
  • Bold + Italics: Use five apostrophes(') on either side. '''''foo'''''
  • Strikethrough: Use the template {{strikethrough}}. {{strikethrough|foo}}
  • Underline: Use the template {{underline}}. {{underline|foo}}
  • small caps: Use the template {{smallcaps}}. {{smallcaps|foo}}
[edit]

To format a link, add the apostrophes around the parentheses: '''[[foo]]''' If you do it the other way around, it will not work since the parentheses interpret the apostrophes as part of the page name.

Line breaks

[edit]
  • If you press ⌅ Enter once, it will place a line break in the markup but not in the rendered result.
  • If you press ⌅ Enter twice, it will insert a line break in the rendered result.
  • Lists are an exception. These require one, not two, markup line breaks.
  • To insert a line break without pressing ⌅ Enter twice, type <br>, <br/>, or {{pb}}. But, use sparingly.

Make lists

[edit]

Bullet lists

[edit]
* a
* b
** c

produces:

  • a
  • b
    • c

Numbered lists

[edit]
# a
# b
## c

produces:

  1. a
  2. b
    1. c
[edit]

Internal pages

[edit]
  • Use [[foo]] to link to an article
  • Use a pipe (|) to insert a parameter which changes what the link says. For example:

Images

[edit]

Link images in the same way that you would link any other internal page. For example, [[File:Abacus 6.png]] gives:

Extended syntax for an image looks something like this:

[[File:Name|Type|Border|Location|Alignment|Size|link=Link|alt=Alt|page=Page|lang=Langtag|Caption]]

Here, only File is technically necessary. Most images only require:

[[File:Name|thumb|alt=Alt|Caption]]

Here, thumb stands in for the size parameter.

Alt text
[edit]

Please: always insert alt text! Alt text describes visual content for users of screen readers and other visual-to-auditory assistive technologies. Rule of thumb: write out alt text as if you're describing the image to someone in another room.

Other language Wikipedias

[edit]
  • Look up the two-letter language code per ISO 639-1.
    • This is the same two-letter code at the beginning of the URL which takes you to that specific language Wikipedia.
    • For example, en.wikipedia.org with the ISO 639-1 code en (English) takes you to the English Wikipedia.
  • Use : two-letter language code : article name to link directly to the other-language Wikipedia page
    • For example, [[:fa:زرتشت]] gives fa:زرتشت. This is the Farsi page for Zarathustra
    • You can use what's called the "pipe trick" (add a pipe symbol(|) to the end of the article name) to have the output only display the article name
    • Or, as you did in previous sections, use a pipe (|) to insert a parameter which changes what the link says

Pages that exist in other languages but not in English

[edit]

Other Wikimedia projects

[edit]

Wikidata and Reasonator

[edit]
[edit]
  • Use [foo] to add an external, non-Wikimedia link
    • Technically, any link (even internal links) can be made this way, but the internal link rules (using [[foo]]) make those look much cleaner
  • Use a space ( ) to label the link. For example:

Communication

[edit]

Sign

[edit]
  • Signing is an etiquette on anonymous platforms! Use tildes(~) to sign off on comments, add yourself to Wikiprojects, etc.
    • ~~~: Three tildes(~) produce your signature Utl jung (talk)
    • ~~~~: Four tildes(~) produce your signature + timestamp Utl jung (talk) 17:13, 7 August 2020 (UTC)
      • Use this one on talk pages
    • ~~~~~: Five tildes(~) produce a timestamp 17:13, 7 August 2020 (UTC)

Ping

[edit]
  • You can notify ("ping") a user by making an edit that links to their user page.
    • Typing @Username will not automatically ping the user.
  • There are many ways to do this. To use myself (User:Utl_jung) as an example, you can write:
    • {{u|Utl_jung}} gives Utl_jung and notifies the user (this option does not append an "@")
    • {{ping|Utl_jung}} gives @Utl jung: and notifies the user
    • {{re|Utl_jung}} gives @Utl jung: and notifies the user

Indent

[edit]

On talk pages, add a colon(:) to indent every time you reply within a thread. For example:

Hello world! ~~~~
:I see your comment. ~~~~
::{{re|Utl_jung}} I, too, see your comment. ~~~~

produces:


Hello world! Utl jung (talk) 17:13, 7 August 2020 (UTC)

I see your comment. Utl jung (talk) 17:13, 7 August 2020 (UTC)
@Utl jung: I, too, see your comment. Utl jung (talk) 17:13, 7 August 2020 (UTC)

Outdent

[edit]

Once there are too many indents, it can help to {{outdent}} ({{out}} for short) for better readability. For example:

[...]
:::::The latest in a long thread of comments. ~~~~
{{out|:::::}}{{re|Utl_jung}} Let's reset the indents for readability. ~~~~

produces:


[...]

The latest in a long thread of comments. Utl jung (talk) 17:13, 7 August 2020 (UTC)

@Utl jung: Let's reset the indents for readability. Utl jung (talk) 17:13, 7 August 2020 (UTC)


Documentation

[edit]

When writing documentation, it can help to know a few templates and HTML snippets which make it easier to distinguish input from output.

  • Use <nowiki>...</nowiki> to escape all contained Wiki markup
  • Use <code>...</code> to stylise contained text as code
  • Use {{tl}} to write about a template without triggering the template itself
    • To use, write: {{tl + | + template name + }}
    • For example, {{tl|archival records}} displays the link to, but does not trigger, {{archival records}}

Transclusion

[edit]
This section is visible here; this section is also visible there. Sections outside of these tags will be visible here, but will not be visible there.  … {{#ifeq:SECTIONNAME|SECTIONNAME|</syntaxhighlight>

End each such transcludable section with:

}}</onlyinclude>
Target document markup
[edit]

To transclude a section marked as above into another page (the "target page"), use the following line on that page, substituting PAGENAME for the "source" document from which text to be transcluded, and SECTIONNAME with the name of the section you want to transclude:

{{PAGENAME|transcludesection=SECTIONNAME}}

Thus each section enclosed within <onlyinclude></onlyinclude> tags will always be rendered when the transcludesection parameter is not set (when the document is viewed ordinarily, or when the document is transcluded without setting the transcludesection parameter as shown below), and will be rendered by transclusion on any page that does set transcludesection to the section's name. It will not be rendered by transclusion that uses the transcludesection parameter but sets it to anything other than the name of the section.

Also, when providing PAGENAME, without providing a Namespace, the wiki will assume that the PAGENAME belongs in the Template Namespace. To transclude from a Mainspace article, use :PAGENAME.

{{:PAGENAME|transcludesection=SECTIONNAME}}
Example
[edit]

If we want to make the "Principal Criteria" and "Common Name" sections of WP:TITLE be independently transcludable, we edit the WP:TITLE page and enclose the "Principal Criteria" section as follows:

<onlyinclude>{{#ifeq:{{{transcludesection|principalcriteria}}}|principalcriteria|
...
''(text of "Principal Criteria" section)''
...
}}</onlyinclude>

Similarly, we enclose the "Common Name" section with:

<onlyinclude>{{#ifeq:{{{transcludesection|commonname}}}|commonname|
...
''(text of "Common Name" section)''
...
}}</onlyinclude>

Then, to transclude the "Principal Criteria" section into another page, we insert into that page:

{{WP:TITLE|transcludesection=principalcriteria}}

To transclude the "Common Name" section into another page, we insert into that page:

{{WP:TITLE|transcludesection=commonname}}

Of course, the same page can transclude two or more sections this way by including multiple such lines.

There is no limit to how many selectable sections for transclusion a document can have. The only requirement is that each transcludesection be given a value that is unique within that page.

Additional markup for selectively transcluded sub-article leads
[edit]

Per MOS:LEAD § Format of the first sentence, the first instance of the sub-article title should appear in bold in the first lead sentence of that article; this is often not desirable for a transclusion to a section of the parent article. In addition, the parent article is often wikilinked in the lead of a sub-article; when transcluded to the parent article, this wikilink will appear as bold text. The wikitext markup listed below can be used to address both of these problems.

To ensure that the article title is bolded in the first sentence of the sub-article, but unbolded and wikilinked in the transclusion to the parent article, make the following replacement in the sub-article's first lead sentence:

Replace
SUB-ARTICLE_PAGENAME
with
<noinclude>'''</noinclude>{{No selflink|{{var|SUB-ARTICLE_PAGENAME}}}}<noinclude>'''</noinclude>

If there is a wikilink to the parent article in the lead section of the sub-article, replacing the wikilink to the parent article with a {{no selflink}} template will ensure that it is wikilinked in the sub-article's lead but not in the transclusion to the parent article. In other words:

  1. If the wikilink to the parent article is not a WP:Piped link, replace [[PARENT_ARTICLE]] with {{no selflink|PARENT_ARTICLE}} in the sub-article's lead
  2. If the wikilink to the parent article includes a pipe (e.g., this link), replace [[PARENT_ARTICLE|Piped link wikitext]] with {{No selflink|PARENT_ARTICLE|Piped link wikitext}} in the sub-article's lead

Drawbacks

[edit]

Like many software technologies, transclusion comes with a number of drawbacks. The most obvious one being the cost in terms of increased machine resources needed; to mitigate this to some extent, template limits are imposed by the software to reduce the complexity of pages. Some further drawbacks are listed below.

Special pages

[edit]

Some pages on Special:SpecialPages can be transcluded, such as AllPages, PrefixIndex, NewFiles, NewPages, RecentChanges, WhatLinksHere (see help page), and RecentChangesLinked. Samples:

  • {{Special:AllPages/General}} – a list of pages starting at "General".
  • {{Special:PrefixIndex/General}} – a list of pages with prefix "General".
  • {{Special:NewFiles/4}} – a gallery of the four most recently uploaded files.
  • {{Special:NewPages/5}} – a list of the five most recently created pages.
  • {{Special:RecentChanges/5}} – the five most recent changes.
  • {{Special:RecentChangesLinked/General}} – recent changes to the pages linked from "General".
  • {{Special:Contribs/Larry Sanger|offset=20021108002158|limit=50}} – user contributions prior to November 2002, limited to 50.

Attempting to transclude {{Special:Categories}} will not result in an actual list of categories, but {{Special:PrefixIndex/Category:}} can be used for this purpose.

Except for Special:RecentChangesLinked, the slash, and the word or number after the slash, can be omitted, giving a list of pages without a specific starting point, or a list of the default length.

URL parameters can be given like template parameters:

  • {{Special:RecentChanges|namespace=10|limit=5}} – the five most recent changes in the "Template" namespace.
  • {{Special:PrefixIndex/Jimbo Wales/|namespace=2|stripprefix=1}} – the subpages for User:Jimbo Wales, but without the user page prefix. {{Special:PrefixIndex/User:Jimbo Wales/|stripprefix=1}} (where the special page presumes mainspace with the user prefix directly specified as part of the title) performs the same function.

Note: Transcluding certain special pages (such as Special:NewPages) can change the displayed title of the page.

Advanced concepts

[edit]

Transclusion occurs before parsing and can emit syntax fragments, like HTML entities, to preserve them in the final render. The content being transcluded is processed and embedded before the target page is parsed and fully rendered. When transclusion happens at the HTML layer before parsing, it allows certain content – like syntax fragments such as character entity references like &amp; or specific HTML components – to be inserted in their original form and preserved in the final render. However, this approach may cause pages to render incorrectly or violate the principle of least surprise for the reader.[a] It should be used sparingly when cleaner alternatives are not available.

Emitting fragments of template syntax, such as opening braces ({{}}), is unlikely to re-parse correctly as template syntax in the target page, and it is unwise to rely on such behavior unless formally documented. While it is sometimes the only way to do something that needs to be done, you should really try to see if there is some other way to do it first.

Notes

[edit]
  1. For example, if whitespace, tabs, and newline HTML code are preserved without parsing, the final page may display awkward spacing, misalignments, or unexpected breaks. This whitespace is usually added in the source code to improve readability for developers and isn’t intended to appear in the published content.

See also

[edit]

MediaWiki transclusion

[edit]

Templates

[edit]

Other

[edit]

Journey ahead

[edit]

Once comfortable with the basics of Wiki markup, I highly recommend that you reference these wonderful existing documentation pages to do more and more things with Wiki markup!

Nifty customisation!

[edit]
  • Syntax highlighter tool - allows custom coloured highlighting for Wiki markup syntax.
    • Enable under Preferences (user toolbar in the top right) > Gadgets


  • Meow
  • meow
  • meow
  1. meow
  2. meow
  3. meow

meow meow about