Skip to content

nerdishbynature/JSDiff.swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSDiff

Build Status codecov.io

A Swift wrapper around JsDiff.

Installation

Carthage is currently the only supported installation method:

github "nerdishbynature/JSDiff.swift"

Usage

Diffing words

Simply put your desired colors into the JSDiff initializer where deletedColor is the lighter color and deletedWordColor is the one that should be more prominent (see the example image).

This method will result a JSLineDiff which has 2 attributed strings containing the diff.

let oldLine = "... something"
let newLine = "..."

let jsDiff = JSDiff(deletedColor: UIColor.deletedColor(), deletedWordColor: UIColor.strongDeletedColor(), addedColor: UIColor.addedColor(), addedWordColor: UIColor.strongAddedColor())

let result = jsDiff.diffWords(oldLine, newLine: newLine)
oldLineLabel.attributedText = result.oldLine
newLineLabel.attributedText = result.newLine

added removed

License

See LICENSE file for more details

About

A Swift wrapper around JsDiff.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors