Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Manual:Extending wiki markup

From mediawiki.org
Translate this page
Languages:
Magic words

MediaWiki provides a standard text markup that can be easily customized.Extensions can customize wiki markup by:

  • Adding standard token types – The standard approach to customized MediaWiki markup is to add new markup that looks like the built-in MediaWikiXML tags (<tag>),template ({{...}}), or link markup ([[...]]).
  • Adding custom token types – Some extensions define new token types.
  • Making fundamental changes to the parser – A few extensions attempt to fundamentally change the parsing strategy so that other markup languages can be used instead of the standard wiki markup.

Adding to the standard token types

[edit]

The simplest way to extend wiki markup is by adding to a standard token type using one of these features.

Variables

[edit]

A variable calls a PHP function that outputs a string ofWikitext that replaces the variable on the page.Variables are usually used to insert system information into wiki markup, such as the current time or the current page.

Syntax example:

{{VARIABLENAME}}

To define a variable, seeManual:Variables.For a list of extensions that define custom variables, seeCategory:Variable extensions.

Parser functions

[edit]

Like variables, a parser function calls a PHP function and outputs a wikitext string that replaces the parser function on the page.Unlike variables, a parser function can pass parameters to the PHP function.Parser functions are used to handle wikitext generation that involves logic that is too complex or confusing to write using templates.

Syntax example:

{{#functionname: param1| param2}}

To define a parser function, seeManual:Parser functions.For a list of extensions that define custom parser functions, seeCategory:Parser function extensions.

Parser tags

[edit]

Unlike variables and parser functions, which output wikitext, parser tags output HTML.A parser tag is anXML tag that calls a PHP function, parses the contents of the tag, and outputs HTML that replaces the tag and its contents on the page.Parser tags can also pass arguments to the PHP function.For example,‎<syntaxhighlight> is a parser tag defined byExtension:SyntaxHighlight.

Syntax example:

<tagnameparam1name="param1value"param2name="param2value">sometext</tagname>

To define a parser tag, seeManual:Tag extensions.For a list of extensions that define custom parser tags, seeCategory:Tag extensions.

Behavior switches

[edit]

A behavior switch calls a PHP function, but, unlike other methods of extending wiki markup, behavior switches usually do not output any content.Instead, they change the behavior of the page or set a page property.For example, adding__NOTOC__ to a page hides the table of contents.

Syntax example:

__SWITCHNAME__

To define a behavior switch, seeManual:Magic words.For a list of extensions that define custom behavior switches, seeHelp:Magic words.

Link markup

[edit]

Link markup customizations change the way MediaWiki interprets internal links.

Syntax example:

[[ ...]]

For a list of extensions that define custom link markup, seeCategory:Link markup extensions.

Adding new token types

[edit]

To add new token types or to change the entire markup strategy, implementers need to add functions to one or more of the various parser and page outputhooks:

See alsoCategory:Extensions by hook usage.

See also

[edit]
  • Manual:Extensions - provides general instructions for finding, installing, and writing extensions.
Setup
Implementation
Extension points
General
Pages
Content
Wiki markup
Moderation
Authentication
Best practices
Tools
Retrieved from "https://www.mediawiki.org/w/index.php?title=Manual:Extending_wiki_markup&oldid=7886648"
Categories:

[8]ページ先頭

©2009-2025 Movatter.jp