MediaWiki API 說明

此頁為自動產生的 MediaWiki API 說明文件頁面。

說明文件與範例:https://www.mediawiki.org/wiki/Special:MyLanguage/API:Main_page

action=parse

main | parse

解析內容併回傳解析器輸出。

查看 action=query 的各種道具模組來從目前頁面版本取得資訊。

以下有幾種方式來解析指定文字:

  1. 要指定頁面或修訂,請使用 pagepageid、或是 oldid
  2. 要指定明確內容,請使用 texttitlerevid 以及 contentmodel
  3. 要指定解析的摘要,prop 應提供一個空值。
參數:
title

文字所屬的頁面標題。若省略,需要指定 contentmodel,且 API 會用為標題使用。

text

要解析的文字。使用 titlecontentmodel 來控制內容模組。

revid

修訂 ID,用於 {{REVISIONID}} 和相似變數。

類型:整數
summary

解析摘要。

page

解析此頁面的內容。不能與 texttitle 一起使用。

pageid

解析此頁面的內容。覆蓋 page

類型:整數
redirects

page 或者 pageid 被設定成重新導向,則解析它。

類型:布林值(詳細資訊
oldid

解析此修訂的內容。覆蓋 pagepageid

類型:整數
prop

要取得的資訊部份:

text
提供 wikitext 的解析文字。
langlinks
在已解析的 wikitext 提供語言連結。
categories
在已解析的 wikitext 提供分類。
categorieshtml
提供分類的 HTML 版本。
links
在已解析的 wikitext 提供內部連結。
templates
在已解析的 wikitext 提供模板。
images
在已解析的 wikitext 提供圖片。
externallinks
在已解析的 wikitext 提供外部連結。
sections
在已解析的 wikitext 提供段落。
revid
添加已解析頁面的修訂 ID。
displaytitle
添加已解析 wikitext 的標題。
subtitle
為解析頁面添加頁面副標題。
headhtml
給予頁面已解析的 doctype、開啟的 <html><head> 元素、以及開啟的 <body>
modules
在頁面提供使用的 ResourceLoader 模組。要載入請使用 mw.loader.using()jsconfigvarsencodedjsconfigvars 其一必須與 modules 一同被請求。
jsconfigvars
針對頁面提供指定的 JavaScript 設置變數。若要套用,請使用 mw.config.set()
encodedjsconfigvars
指定頁面的 JavaScript 設置變量為 JSON 字串。
indicators
提供使用在頁面的頁面狀態指示 HTML。
iwlinks
在已解析的 wikitext 提供跨 wiki 連結。
wikitext
指定被解析的原始 wikitext。
properties
指定多項定義在已解析原始 wikitext 的屬性。
limitreportdata
取得結構化限制報告。當有設定 disablelimitreport 時,則不會給予資料。
limitreporthtml
取得限制報告的 HTML 版本。當有設定 disablelimitreport 時,則不會給予資料。
parsetree
修訂內容的 XML 解析樹狀(需要內容模型 wikitext
parsewarnings
提供發生在解析內容時的警告(以 wikitext)。
parsewarningshtml
提供發生在解析內容時的警告(以 HTML)。
headitems
已棄用。提供放置頁面裡的 <head> 之項目。
多值 (以 |alternative 分隔):categories、​categorieshtml、​displaytitle、​encodedjsconfigvars、​externallinks、​headhtml、​images、​indicators、​iwlinks、​jsconfigvars、​langlinks、​limitreportdata、​limitreporthtml、​links、​modules、​parsetree、​parsewarnings、​parsewarningshtml、​properties、​revid、​sections、​subtitle、​templates、​text、​wikitext、​headitems
預設值:text|langlinks|categories|links|templates|images|externallinks|sections|revid|displaytitle|iwlinks|properties|parsewarnings
wrapoutputclass

要包在解析器輸出內容的 CSS 類別。

預設值:mw-parser-output
pst

在解析之前執行在輸入裡的預先儲存轉換。僅當與文字使用時有效。

類型:布林值(詳細資訊
onlypst

在輸入裡進行預先儲存轉換(pre-save transform、PST)但不解析。在 PST 已套用後回傳相同的 wikitext。僅與 text 使用時有效。

類型:布林值(詳細資訊
effectivelanglinks
已棄用。

包含由擴充提供的語言連結(與 prop=langlinks 一起使用)。

類型:布林值(詳細資訊
section

僅解析帶有此識別碼的段落之內容。

當為 new 時,解析 textsectiontitle,如同添加新段落至頁面裡。

new 僅在有指定 text 時允許。

sectiontitle

新段落標題當 sectionnew 時。

不像頁面編輯,當省略或為空時不會退至 summary

disablepp
已棄用。

請改用disablelimitreport

類型:布林值(詳細資訊
disablelimitreport

從解析輸出內容裡省略限制報告("NewPP limit report")。

類型:布林值(詳細資訊
disableeditsection

從解析輸出內容省略編輯段落連結。

類型:布林值(詳細資訊
disablestylededuplication

不要在解析結果去除重複的行內樣式表。

類型:布林值(詳細資訊
showstrategykeys

是否在jsconfigvars中包含内部合并策略信息。

類型:布林值(詳細資訊
generatexml
已棄用。

產生 XML 解析樹狀(需要被 prop=parsetree 給取代的 wikitext 內容模型)。

類型:布林值(詳細資訊
preview

在預覽模式下解析。

類型:布林值(詳細資訊
sectionpreview

在段落預覽模式下解析(要同時啟用預覽模式)。

類型:布林值(詳細資訊
disabletoc

在輸出裡忽略目錄。

類型:布林值(詳細資訊
useskin

套用所選的外觀至解析輸出。可能會影響以下參數:langlinksheaditemsmodulesjsconfigvarsindicators

單值:apioutput、​fallback、​minerva、​monobook、​timeless、​vector、​vector-2022
contentformat

用於輸入文字的內容序列格式。僅與 text 一起使用時有效。

單值:application/json、​application/octet-stream、​application/unknown、​application/x-binary、​text/css、​text/javascript、​text/plain、​text/unknown、​text/x-wiki、​unknown/unknown
contentmodel

輸入文字的內容模組。若省略則必須指定 title,且預設會是指定標題的模組。僅在與 text 一起使用時有效。

單值:css、​javascript、​json、​text、​unknown、​wikitext