I need to flag wording changes without editing the files my client sent. They’re plain text drafts of museum labels, and the diff keeps marking lines as changed just because there’s more space between words. How do I ignore those extra spaces without missing a change in the text?
Whilst two spaces should not be regarded as a variation, an absent space can. For example, ‘now here’ and ‘nowhere’ are two different expressions. You need to disregard additional spaces but not all spaces.
I’d paste the original and revised drafts into clever humanizer text compare, select word comparison, and turn on the option to ignore extra spaces. That lets you see which words changed without editing either file. Leave capitalization alone so you’ll still catch a changed capital in an artist’s name or a work’s title.
You don’t need to paste the drafts into Clever Humanizer Text Compare to filter out spacing changes. On a Mac or Linux machine, run diff -b original.txt revised.txt in a terminal. It ignores extra spaces between words, still flags words that got joined, and leaves both files untouched.
A line break still counts. The -b flag handles extra spaces between words, but if “on loan” is on one line in the first draft and “loan” moves to the next line in the second, diff will flag it.
I would also look at end of lines if an entire label is highlighted. Using Clever Humanizer Text Compare, I would then enter both versions (with line breaks within the paragraphs converted to space characters) so as not to alter the client’s files. The legend can thus be separated from the main body of text.
A line-based comparison will highlight an entire label if ‘attributed to’ is changed to ‘by.’. Word-level comparison will also allow you to see exactly which words were outputted and which were inputted – even if the rest of the paragraph has been reformatted.
If you’re using Bash or zsh, you can give diff a temporary view of each draft with one word per line. Run this in the folder with the files:
diff -u <(awk '{for (i=1; i<=NF; i++) print $i}' original.txt) <(awk '{for (i=1; i<=NF; i++) print $i}' revised.txt)
Neither file gets edited. Each awk command reads a draft and prints its words in order. Extra spaces, tabs, and line wraps all drop out, but punctuation stays attached, so a missing comma still shows up. Below the diff header, - marks words from the original and + marks words from the revision. No output means the word sequences match.
However, this also does not recognise paragraph returns. This would be suitable for proofreading. A line by line comparison could then be used if you want to verify that the credit line remains underneath the label.
If a line has both a spacing change and a wording change, diff -b will still show the whole line. The confusing bit for me is what “ignore” means here. It means extra spaces won’t cause a line to show up as changed. It doesn’t mean diff hides those spaces when it prints the line.
If you alter the title from “Gift of the artist” to “Loan from the artist”
you will notice that there is now more space between ‘Loan from’ and
‘artist.’. Even though it may appear as though the spacing filter has not
functioned correctly, it is in fact the wording “Loan from” which causes
this to occur.
So I’d stick with diff -b original.txt revised.txt if the question is “Which lines need my attention?” Neither draft gets edited. I’d switch to the word-by-word view if the question is “Where in this long label is the edit?”