Manual:Extending wiki markup/id
Appearance
MediaWiki provides a standard text markup that can be easily customized. Both piecemeal and wholesale customizations are possible:
- adding custom token types: Some extensions define new token types.
- fundamental changes to the parser: A few extensions attempt to fundamentally change the parsing strategy so that markup from other sorts of wikis and content management can be used (must be used?) instead of the standard wiki markup.
Adding to the standard token types
- Parser function extensions : Parser function extensions extend parameterized template processing and typically look something like this:
{{#funcname ...}}
. Although any "template name" can be used, custom extensions always begin the function name with a #, as in the example above. Other parser function names are reserved for use by the MediaWiki core.
When{{#funcname ...}}
is implemented as a parser function, it passes its template parameters to a PHP function instead of the usual template article. This function returns a string of wikitext that replaces the parameterized template. Parser functions are used to handle wikitext generation that involves logic that is too complex or confusing to write using normal template-writing techniques. - Variable extensions : Variable extensions extend parameterless template processing.
Instead of the usual article transclusion,{{XXX}}
is associated with a PHP function that returns a string of wikitext that replaces it. They are usually used to insert system information into wiki markup (e.g., the current time, the current page). - XML markup extensions : XML markup extensions (also known as tag extensions) define custom XML-style tags in the wikitext: The text between the tags gets passed on to a PHP function which parses the contents of the tag and returns an HTML string that replaces the tag and text. The content inside the tags may be wiki markup, straight text, or text with formatting rules specific to the tag. It is up to the extension implementer. Silakan periksa dokumentasi ekstensi masing-masing.
<tagname parname="parvalue" ... parname="parvalue"> some text </tagname>
- Link markup extensions : Link markup extensions change the way MediaWiki interprets internal links, i.e., wiki markup of the form [[...]].
- Extended syntax extensions : Extended syntax extensions, mostly Magic Word extensions, add to the list of MediaWiki Magic Words, such as
__NOTOC__
. Usually, a specific PHP function interprets these words, and either replaces them with something, or sets some conditions for later processing during output generation, or both. Most usually, the replacement is the empty string; that is, the Magic Word is deleted, and nothing is shown in its place. Altered processing may involve addition of an extra piece of CSS, or suppression of user preference settings during page generation, and can be almost anything.
Adding new token types
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 output hooks:
- Category:ParserBeforeStrip extensions rely on the ParserBeforeStrip hook.
(removed in 1.36)
- Category:ParserBeforeInternalParse extensions rely on the ParserBeforeInternalParse hook.
- Category:OutputPageBeforeHTML extensions rely on the OutputPageBeforeHTML hook.
- Category:ParserBeforeTidy extensions rely on the ParserBeforeTidy hook.
(removed in 1.36)
- Kategori:Ekstensi ParserAfterTidy rely on the ParserAfterTidy hook.
See also Category:Extensions by hook usage .
Lihat pula
- Manual:Ekstensi - memberikan petunjuk umum untuk menemukan, memasang, dan menulis ekstensi.