Browse the docs

diffLines

Compares two texts line by line.

Details #

diffLines(a, b) compares the lines of a and b and returns a record of three lists: removed (in a only), added (in b only) and unchanged (in both, in order). Line endings don't matter.

Parameters #

Takes 2 arguments. {{ diffLines(text, b) }}

Examples #

diffLines("a\nb\nc", "a\nc\nd")
→ { "added" : [ "d" ], "removed" : [ "b" ], "unchanged" : [ "a", "c" ] }
length(diffLines(old, new).added)
→ 2
Sample variableValue
newa c d
olda b

Gotchas #

  • A changed line is a removed line and an added one.