API:Parsing wikitext

These API modules allow calling the parser for preprocessing and rendering.

Retrieving just the raw source wikitext can be done through prop=revisions.

expandtemplates
Returns preprocessed wikitext (comments stripped, templates expanded, etc.)

Parameters

 * : Wikitext to preprocess
 * : Act like the wikitext is on the page specified (default: )
 * This only really matters when parsing links to the page itself or links to subpages, or when using magic words like.

Possible errors
None.

parse
Returns parsed wikitext

Parameters

 * – Disable the PP Report from the parser output. Type: bool
 * – Parse the content of this revision. Overrides  and  . Type: string
 * – Only do a pre-save transform (PST) on the input, don't parse it. Type: bool
 * Returns the same wikitext, after a PST has been applied. Ignored if,   or   is used. Type: bool
 * – Parse the content of this page. Cannot be used together with  and  . Type: string
 * – Parse the content of this page. Overrides . Type: string
 * – Which pieces of information to get. A pipe character  separated list containing one or more of the following options:
 * – Gives the parsed text of the wikitext.
 * – Gives the langlinks the parsed wikitext.
 * – Gives the categories of the parsed wikitext.
 * – Gives the html version of the categories.
 * – Gives the html version of the languagelinks.
 * – Gives the internal links in the parsed wikitext.
 * – Gives the templates in the parsed wikitext.
 * – Gives the images in the parsed wikitext.
 * – Gives the external links in the parsed wikitext.
 * – Gives the sections in the parsed wikitext (TOC, table of contents).
 * – If  was used, specify the ID of the revision parsed.
 * – Adds the title of the parsed wikitext.
 * – Gives items to put in the of the page.
 * – Gives parsed of the page.
 * – Gives interwiki links in the parsed wikitext.
 * NOTE: Section tree is only generated if there are more than 4 sections, if the keyword is present, or if   is explicitly requested and the page contains headings/sub-headings (overrides  ).
 * Type: string


 * – Do a pre-save transform (PST) on the input before parsing it (makes  work properly, expands tildes to signatures, etc.). Ignored if ,   or   is used. Type: bool
 * – If the  parameter is set to a redirect, resolve it. Type: bool
 * – Only retrieve the content of this section number. Type: string
 * – Retrieve the page's TOC (if any exists). Type: string
 * – Summary to parse. Type: string
 * – Wikitext to parse. Type: string
 * – Act like the wikitext is on this page (default: ). Type: string
 * This only really matters when parsing links to the page itself or subpages, or when using magic words like.
 * – The language code ("en" for English, "fr" for French, etc.) of the language in which the text or the page should be parsed. Type: string
 * This is useful for language-dependent content, such as generated by the template at the Commons, or generally by things dependent on  . Prior to MediaWiki 1.17, this worked by accident; since 1.17, it works by design.
 * – Content model of the input text. Default is the model of the specified title, or  if title is not specified. Only valid when used with text. Can be one of the following: wikitext, javascript, css, text, JsonZeroConfig, Scribunto, JsonSchema.
 * – Generate the XML parse tree (requires contentmodel=wikitext). Type: bool

Possible errors
Note:  is returned only for syntactically invalid page titles (eg. empty). Trying to fetching a missing page will return the rendered HTML of the "page missing" notice, not an error. However, you can check the  attribute of, which will always be   for missing pages.
 * – There is no revision ID oldid
 * – The page you specified doesn't exist
 * – There is no page with ID $1
 * – There is no section sectionnumber in page
 * – The page parameter cannot be used together with the text and title parameters
 * – You don't have permission to view deleted revisions
 * – You need read permission to use this module