差异(diff)可用于比较一个页面的两个修订版本间的差异。 差异是 MediaWiki wiki 中页面导航和内容审核的基本组成部分。
维基生态中的平台有不同版本的“差异”,这具体取决于使用的设备和 MediaWiki 的设置。
差异主要用于复查自己或他人对页面做出的改变。 这样做可能有很多原因:
最普遍的做法是通过“历史纪录”检视差异。 这可以通过点击“查看历史”标签访问。 在那里,您可以使用“之前”以查看单次修订的“差异”,或者使用“单选”和“对比所选修订”按钮以查看多次修订的“差异”。
Most special pages that list changes will usually include links to diffs, such as:
Another way to view a diff is with the Special:Diff page.
To use this, you must know the IDs of the revisions you want to compare.
Revision IDs can be retrieved by looking at the diff=123
portion of a diff URL, where 123
is the diff ID.
Additionally, you can use the value of the oldid
parameter to get the diff of that revision against the previous one.
Below is a visual representation of the important components of a diff page which you will see when viewing the difference between two versions.
This interactive example shows the top of the diff page (some of the links are dummy links).
The older revision is shown on the left, the newer revision on the right.
(Edit summaries in diffs are great) 小 (correction, + MediaWiki User's Guide)第8行: 第8行: For sysops and those with the rollback flag, a revert button is shown allowing them to revert from the new version to the old one. For sysops and those with the rollback flag, a revert button is shown allowing them to revert from the new version to the old one. − This is only shown when viewing the diff between the currentversion and the oneimmediately preceding it.+ This is only shown when viewing the diff between the recent version of a page and the last version by an author other than the one of the most current version. This example shows the top of the diff page, with the links described above. This example shows the top of the diff page, with the links described above. 第25行: 第25行: </table> </table> + [[MediaWiki User's Guide]] +
Unchanged text is dark grey on light grey (only parts before and after changed text are shown).
Previous diff | Newer diff | ||
---|---|---|---|
|
Identical text that has moved from one place to another is usually represented as added and removed text. On MediaWiki installations using Wikidiff2 , there may be an arrow icon more clearly indicating where the moved text went to.
Lines containing added text have a plus icon (+) before them. The added words and characters are highlighted and in bold.
Lines containing removed text have a minus icon (−) before them. The removed words and characters are highlighted and in bold.
We can see what has been replaced with new content when there's a + icon and a − icon next to the phrase where the change happened.
Paragraphs which have changed are black on white, with an orange border on the old revision side and a blue border on the new version side.
Inserted and removed text is highlighted with the border color and in bold. Where whole paragraphs have been removed or inserted, no highlighting or bolding is applied and the other side is blank.
Old revision | New revision | ||
---|---|---|---|
|
Old revision | New revision | ||||
---|---|---|---|---|---|
|
Old revision | New revision | ||
---|---|---|---|
|
Diffs can be linked to by copying the URL while viewing the diff — this URL has two parameters, diff
and oldid
.
Linking to a diff from outside a wiki can be done by using the full URL, for example:
https://mediawiki.org/w/index.php?diff=1242287
The diff special page at Special:Diff makes it easier to create shorter URLs which redirect to diffs.
From within a wiki, these links can take the following forms:
[[Special:Diff/1242287]]
→ Special:Diff/1242287 – Shows the diff to the previous revision of the same page.[[Special:Diff/1242287/prev]]
→ Special:Diff/1242287/prev – Shows the diff to the previous revision of the same page.[[Special:Diff/1242287/next]]
→ Special:Diff/1242287/next – Shows the diff to the next revision of the same page.[[Special:Diff/1242287/cur]]
→ Special:Diff/1242287/cur – Shows the diff to the current revision of the same page.[[Special:Diff/1242286/1242287]]
→ Special:Diff/1242286/1242287 – Shows the diff between the specified revisions of the same page which may also be reversed, e.g. [[Special:Diff/1242287/1242286]]
→ Special:Diff/1242287/1242286, though one should avoid this.These links may be used in the edit summary as well as being adapted like any other internal links, e.g. [[Special:Diff/1242286/1242287|see this diff]]
→ see this diff.
For example, the full URL [https://mediawiki.org/w/index.php?diff=1242287 1242287]
could also be written as [[Special:Diff/1242287|1242287]]
.
By default, the later revision of the page is displayed in full below the diff — this can be turned off via a preference ("不在差异下面显示页面内容") or by setting diffonly=1
in the URL.
Links to diffs without the page text can be created:
{{canonicalurl:Special:Diff/1242287|diffonly=1}}
→ https://www.mediawiki.org/w/index.php?title=Special:Diff/1242287&diffonly=1MediaWiki版本: | ≥ 1.35 |
Since MediaWiki 1.35, an inline diff (also known as a unified diff) is available.
As of 2022 this is only available with the wikidiff2 engine.
Inline diffs can be accessed by passing the diff-type=inline
parameter in the URL (example).
MediaWiki版本: | ≥ 1.41 |
As of MediaWiki 1.41, a toggle was added to diff pages that allows users to switch between inline and two-column in the user interface (T336716).
Content added Content deleted
(Edit summaries in diffs are great) 小 (correction, + MediaWiki User's Guide)For sysops and those with the rollback flag, a revert button is shown allowing them to revert from the new version to the old one.
This is only shown when viewing the diff between the
currentversion and the one of a page and the last version by an author other than the one of the most current version.. This example shows the top of the diff page, with the links described above.</table>
[[MediaWiki User's Guide]]
↲ newline
The following changes were introduced for inline diff:
Bugs should be reported on Phabricator under the #MediaWiki-Page-diffs tag.
The following user preferences are available in the "差异" section of the "外观" preferences tab:
Some extensions also add their own preferences related to diffs. One such extension is 扩展:修订滑块 , which can be disabled in preferences using the "不显示修订滑块" preference in that section.