Jump to content

Wikidiff2/JSON diff format

From mediawiki.org
property description
diff

required | array of objects

Each object in the diff array represents a line in a visual, line-by-line comparison between the two revisions.
diff.type

required | integer

The type of change represented by the diff object, either:
  • 0: A line with the same content in both revisions, included to provide context when viewing the diff. The API returns up to two context lines around each change.
  • 1: A line included in the to revision but not in the from revision.
  • 2: A line included in the from revision but not in the to revision.
  • 3: A line containing text that differs between the two revisions. (For changes to paragraph location as well as content, see type 5.)
  • 4: When a paragraph's location differs between the two revisions, a type 4 object represents the location in the from revision.
  • 5: When a paragraph's location differs between the two revisions, a type 5 object represents the location in the to revision. This type can also include word-level differences between the two revisions.
diff.lineNumber

optional | integer

The line number of the change based on the to revision.
diff.text

required | string

The text of the line, including content from both revisions. For a line containing text that differs between the two revisions, you can use highlightRanges to visually indicate added and removed text. For a line containing a new line, the API returns the text as "" (empty string).
diff.highlightRanges

optional | array of objects

An array of objects that indicate where and in what style text should be highlighted to visually represent changes.

Each object includes:

  • start (integer): Where the highlighted text should start, in the number of bytes from the beginning of the line.
  • length (integer): The length of the highlighted section, in bytes.
  • type (integer): The type of highlight:
    • 0 indicates an addition.
    • 1 indicates a deletion.
diff.moveInfo

optional | object

Visual indicators to use when a paragraph's location differs between the two revisions. moveInfo objects occur in pairs within the diff.
  • id (string): The ID of the paragraph described by the diff object.
  • linkId (string): The ID of the corresponding paragraph.
    • For type 4 diff objects, linkId represents the location in the to revision.
    • For type 5 diff objects, linkId represents the location in the from revision.
  • linkDirection (integer): A visual indicator of the relationship between the two locations. You can use this property to display an arrow icon within the diff.
    • 0 indicates that the linkId paragraph is lower on the page than the id paragraph.
    • 1 indicates that the linkId paragraph is higher on the page than the id paragraph.
diff.offset

required | object

The location of the line in bytes from the beginning of the page, including:
  • from (integer): The first byte of the line in the from revision. A null value indicates that the line doesn't exist in the from revision.
  • to (integer): The first byte of the line in the to revision. A null value indicates that the line doesn't exist in the to revision.