CaseLeaf

Handbook / The `diff` command

The diff command

A contract comes back from the other side described as "minor changes" and you need to know what actually moved.

Reports what changed between two documents. It is for the version that came back: what moved, what was added, what quietly went away. A file comparison tells you the bytes differ, which is never the question. This answers in terms of the document.

How you run it

caseleaf diff report.pdf --against reviewed.pdf

caseleaf diff report.pdf --against reviewed.pdf --literal --words

What each part means

In full, every part it will take:

caseleaf diff <file> --against <file> [--literal] [--words]
part what it is for
<file> The PDF to work on, as a path, such as report.pdf beside you, or the full path to it. It is read and not written.
--against The other document, as a path, for example caseleaf diff final.pdf --against draft.pdf. Neither document is changed; what comes back is the comparison.
--literal Compare the words exactly as they are typeset. Normally a curly quote, an en dash, an fi ligature and a non-breaking space each count as the plain character they stand for, and punctuation at the ends of a word is ignored, so a document re-typeset elsewhere does not come back changed on every line. --literal folds none of that away, for when the typography is itself the question, such as a hyphen that has become a minus sign in a formula.
--words Do not compare; list the words of both documents in the order they were read off the paper, with the columns they were read in. This is the one to reach for when the report is full of changes nobody made: a comparison can only line two documents up if it read them in the same order, and this shows the order.

What comes back

Asked of a short sample document, it answers as below. The sample has eight sheets, a highlight and a note left by a reviewer, a web link, a small table, two pictures and one form field already filled in.

{
  "changes" : [

  ],
  "words" : {
    "after" : 84,
    "before" : 84
  }
}

The same thing from AppleScript

Everything above can be asked for from a script instead. There is one AppleScript command, perform: on names the document, and options takes the rest exactly as you would type it.

tell application "CaseLeaf"
    perform "diff" on "/path/to/report.pdf" ¬
        options "--against reviewed.pdf"
end tell

tell application "CaseLeaf"
    perform "diff" on "/path/to/report.pdf" ¬
        options "--against reviewed.pdf --literal --words"
end tell

All the commands · Asking from a script · Contents