API:Parsing wikitext/zh

From MediaWiki.org
Jump to navigation Jump to search



MediaWiki版本: 1.12

返回 preprocessed 维基源代码 (comments stripped, 模板 expanded, etc.)


  • text: 维基源代码 to preprocess
  • title: Act like the 维基源代码 is on the page specified (default: API)
    • This only really matters when parsing links to the page itself or links to subpages, or when using magic words like {{PAGENAME}}


Expand 维基源代码 {{Project:Sandbox}}

Possible errors[edit]



MediaWiki版本: 1.12



  • disablepp:Disable the PP Report from the parser output。 类型: 布尔值
  • oldid:解析 the content of this revision。 Overrides page and pageid类型: 字符串
  • onlypst:Only do a pre-save transform (PST) on the input, don't 解析 it。 类型: 布尔值
    返回 the same 维基源代码, after a PST has been applied。 Ignored if page, pageid or oldid is used。 类型: 布尔值
  • page:解析 the content of this page。Cannot be used together with text and title类型: 字符串
  • pageid:解析 the content of this page。Overrides page类型: 字符串
  • prop:Which pieces of information to get。A pipe character | separated list containing one or more of the following options:
    • text:解析维基源代码,返回HTML。
    • langlinks:获取 the langlinks the 解析后的维基源代码。
    • categories:获取指定的维基源代码中所包含的分类。
    • categorieshtml:获取 the html version of the categories。
    • languageshtml:获取 the html version of the languagelinks。
    • links:获取指定的维基源代码中所包含的内部链接。
    • templates:获取指定的维基源代码中所使用的模板。
    • images:获取指定的维基源代码中所包含的图片。
    • externallinks:获取指定的维基源代码中所包含的外部链接。
    • sections:解析维基源代码,获取所有章节(即目录)。返回值带有以下属性:
      • anchor:.E5.AA.92.E4.BD.93.....E9.A2.98
      • byteoffset:如果该章节是因调用模板产生,则值为null。如果由源代码里的==XXX==产生,则值为标题标记出现的位置。
      • fromtitle:如果该章节是因调用模板产生,则值为false。如果因嵌入页面产生(如{{API:Parsing wikitext/zh}}),则值为被嵌页面的名称。如果由源代码里的==XXX==产生,则值为当前页面的名称。页面名称是url形式(如User_talk:Gqqnb)的,不是规范标题(User talk:Gqqnb)。类型:字符串或布尔值。
      • index:如果该章节是因调用模板产生,则值为空字符串。
      • level:2
      • line:章节标题
      • number:祖先章节的序号与本章节序号。如果该章节是第一个2级标题里的第二个3级标题,则值为number="1.2"。类型:字符串。
      • toclevel:章节的级别。1表示2级标题,由==XXX==产生。
    • revid:If page was used, specify the ID of the revision parsed。
    • displaytitle:Adds the title of the 解析后的维基源代码。
    • headitems:获取 items to put in the <head> of the page。
    • headhtml:获取 parsed <head> of the page。
    • iwlinks:获取 interwiki links in the 解析后的维基源代码。
NOTE: Section tree is only generated if there are more than 4 sections, if the __TOC__ keyword is present, or if sections is explicitly requested and the page contains headings/sub-headings (overrides __NOTOC__)。
类型: 字符串
  • pst:Do a pre-save transform (PST) on the input before parsing it (makes {{subst:}} work properly, expands tildes to signatures, etc.)。Ignored if page, pageid or oldid is used。类型:布尔值
  • redirects:If the page parameter is set to a redirect, resolve it。类型:布尔值
  • section:Only retrieve the content of this section number。类型:字符串
  • sections:Retrieve the page's TOC (if any exists)。类型:字符串
  • summary:Summary to 解析。类型:字符串
  • text:维基源代码 to 解析。类型:字符串
  • title:Act like the 维基源代码 is on this page (default: API)。类型: 字符串
    This only really matters when parsing links to the page itself or subpages, or when using magic words like {{PAGENAME}}
  • uselang:The language code ("en" for English, "fr" for French, etc.) of the language in which the text or the page should be parsed。类型: 字符串
    This is useful for language-dependent content, such as generated by the {{LangSwitch}} 模板 at the Commons, or generally by things dependent on {{int:Lang}}。Prior to MediaWiki 1.17, this worked by accident; since 1.17, it works by design。
  • contentmodel:Content model of the input text。Default is the model of the specified title, or wikitext if title is not specified。Only valid when used with text。Can be one of the following: 维基源代码, javascript, css, text, JsonZeroConfig, Scribunto, JsonSchema。
  • generatexml:Generate the XML parse tree (requires contentmodel=wikitext)。 类型: 布尔值


解析维基源代码 [[foo]] [[API:Query|bar]] [http://www.example.com/ baz]


  • missingrev:There is no revision ID oldid
  • missingtitle:The page you specified doesn't exist
  • nosuchpageid:There is no page with ID $1
  • nosuchsection:There is no section sectionnumber in page
  • params:The page parameter cannot be used together with the text and title parameters
  • permissiondenied:You don't have permission to view deleted revisions
  • readapidenied:You need read permission to use this module

Note: missingtitle is returned only for syntactically invalid page titles (eg. empty)。Trying to fetching a missing page will 返回 the rendered HTML of the "page missing" notice, not an error。However, you can check the revid attribute of <param>, which will always be 0 for missing pages。