lua-differ/README.md
Bruce Hill c47c4a2e41 Tweak.
2017-10-26 02:25:05 -07:00

49 lines
729 B
Markdown

# LuaDiffer: A simple lua diff library
This is a simple lua module that performs a diff on two strings and returns a table of
string chunks.
## Example
```lua
make_diff = require "diff"
s1 = [[hello
...
to the
world]]
s2 = [[hello
...
*at* the
world]]
diff = make_diff(s1, s2)
```
returns the table:
```
{
{old="hello\n...\n", old_line=1, old_line_end=2,
new="hello\n...\n", new_line=1, new_line_end=2},
{old="to the\n", old_line=3, old_line_end=3,
new="*at* the\n", new_line=3, new_line_end=3},
{old="world", old_line=4, old_line_end=4,
new="world", new_line=4, new_line_end=4},
}
```
and running:
```lua
diff:print{color=false}
```
produces the output:
```
hello
...
- to the
+ *at* the
world
```