Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-REVIEW-009

A changed block shows as a side-by-side diff with its word marks, cut by line hunks, and a malformed baseline message is dropped

While the side-by-side diff is on and a baseline for the current render is held, the page SHALL replace each block that changed since the last commit by a card with the rendered block at the last commit on the left and the rendered current block on the right, keep on the left of a block that lies inside one hunk only the block at the last commit that shares the most words with it (each kept by one block at most) and show the other blocks at the last commit of that hunk as removed blocks in their source order, mark the removed words on the left and the added words on the right, leave the left empty for an added block and show a removed block with an empty right side, leave unchanged blocks as they are, and show the original blocks again when the diff goes off or the baseline is stale; the baseline message previewBaselineDiff is accepted only with an html string of at most 20 MiB and at most 100 000 hunks of non-negative integer lines whose ends are not more than one before their starts, for the current render, and any other is dropped; the removed and added words are the character ranges found by comparing the block at the last commit with the current block word by word, consecutive changed words merged into one range, all words of both texts being marked when the comparison would exceed 4 000 000 word pairs; the changed blocks are found from line hunks that give the last-commit lines and the current lines as 1-based inclusive ranges, with an empty side for lines only added or only removed, merged with the hunk next to them when only blank lines separate them, ignoring differences of line endings, and reported as one hunk when more than 20 000 lines differ or more than 2000 edits are needed.

Step 3 of path 1 in StRS-MDOKFSTUDIO-REVIEW-018: from “The page holds the baseline” to “Changed blocks show as cards”.

Scenarios 8

The situations the tests check; open one to read it.

nominalCards for changed blocks
InputOutcome
A block with changed wordsa card of two columns: the block at the last commit on the left with the removed words marked, the current block on the right with the added words marked; the original block is hidden
An added blocka card with an empty left side
A removed blocka card with the removed block on the left and an empty right side, in the place of the removal
A list or table with a changed item or rowone card with the whole list or table on both sides
A paragraph removed next to an edited one (one hunk holds both)the edited paragraph is a card with its own text at the last commit on the left (the one that shares the most words with it); the removed paragraph is a card with an empty right side, before or after it in source order
Two blocks inside one hunk that holds one block at the last committhe block that shares the most words with it keeps it on its left; the other is an added block
An unchanged blockshown as it is, no card
boundaryGoing back
InputOutcome
The diff switched off, or edit mode onthe cards go away and the original blocks show again
A baseline of an older render than the page contentno card is made
A baseline whose hunks are emptyno card is made
The page content is patchedthe cards are made again from the held baseline when it matches the new content
nominalA well-formed baseline message
InputOutcome
previewBaselineDiff with an html string and hunks of non-negative integers whose ends are at least one before their startsaccepted for the current render
refusalDropped baseline messages
InputOutcome
previewBaselineDiff with a non-string html, no hunks, a negative or fractional line, an end more than one before its start, or a null hunkdropped
An html of more than 20 MiB, or more than 100 000 hunksdropped
A baseline message of a stale renderdropped
nominalChanged words of a card
InputOutcome
Two identical textsno range on either side
One word replacedthat word is removed on the old side and added on the new side
Several consecutive words replacedone range per run, the space between them included
Separate changesseparate ranges
Words only inserted or only deletedranges on one side only
Texts that come in pieces (text nodes)compared as one text in which a piece boundary separates words, the ranges given inside their piece
boundaryWord diff size limit
InputOutcome
Texts of more than 4 000 000 word pairsall words of both texts are marked
nominalHunks with both sides
InputOutcome
Two identical texts, or texts that differ only by line endingsno hunk
One line modifiedone hunk with the same line on both sides
Lines addeda hunk whose base side is empty (base end one before base start)
Lines removeda hunk whose current side is empty (end one before start)
Two separate editstwo hunks
Lines removed and added before the next common lineone hunk
Lines removed (or added) next to a changed line, only blank lines between them on both sidesone hunk that holds both and the blank lines between them
Lines removed (or added) next to a changed line, a heading or any other non-blank line between themtwo hunks
Two changed lines (both sides not empty), only blank lines between themtwo hunks
boundaryHunk size limits and block mapping
InputOutcome
More than 20 000 differing lines, or more than 2000 editsone hunk covers the whole differing middle
A block of the current text and the hunksthe block is changed when it meets a hunk with current lines or holds a removal; its base lines are the base side of the hunk it lies in, or its own lines shifted by the hunks before it

Implemented in 5

Tested by 9

Replaces

SwRS-MDOKFSTUDIO-REVIEW-005The word diff reports the added and removed words superseded superseded by SwRS-MDOKFSTUDIO-REVIEW-009 Markdown file
SwRS-MDOKFSTUDIO-REVIEW-007The side-by-side messages are validated and gated superseded superseded by SwRS-MDOKFSTUDIO-REVIEW-006, SwRS-MDOKFSTUDIO-REVIEW-009 Markdown file
SwRS-MDOKFSTUDIO-REVIEW-010The line diff reports hunks with both sides superseded superseded by SwRS-MDOKFSTUDIO-REVIEW-009 Markdown file