From 29e0e0fdd41aa0e90bc344da3ac8fa2fa0d407f2 Mon Sep 17 00:00:00 2001 From: Arnab Deka Date: Wed, 29 Apr 2015 08:59:52 -0700 Subject: [PATCH] bump version to 1.0.4. See PR #6 and Issue #9. --- jquery.pretty-text-diff.js | 17 +++++++++++------ jquery.pretty-text-diff.min.js | 6 +++--- pretty-text-diff.jquery.json | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/jquery.pretty-text-diff.js b/jquery.pretty-text-diff.js index 1e8fec7..8c4d624 100644 --- a/jquery.pretty-text-diff.js +++ b/jquery.pretty-text-diff.js @@ -1,9 +1,9 @@ -// Generated by CoffeeScript 1.6.3 +// Generated by CoffeeScript 1.9.2 + /* -@preserve jQuery.PrettyTextDiff 1.0.3 +@preserve jQuery.PrettyTextDiff 1.0.4 See https://github.com/arnab/jQuery.PrettyTextDiff/ -*/ - + */ (function() { var $; @@ -25,9 +25,14 @@ See https://github.com/arnab/jQuery.PrettyTextDiff/ dmp = new diff_match_patch(); return this.each(function() { var changed, diff_as_html, diffs, original; - original = $(settings.originalContainer, this).text(); + if (settings.originalContent && settings.changedContent) { + original = $('
').html(settings.originalContent).text(); + changed = $('
').html(settings.changedContent).text(); + } else { + original = $(settings.originalContainer, this).text(); + changed = $(settings.changedContainer, this).text(); + } $.fn.prettyTextDiff.debug("Original text found: ", original, settings); - changed = $(settings.changedContainer, this).text(); $.fn.prettyTextDiff.debug("Changed text found: ", changed, settings); diffs = dmp.diff_main(original, changed); if (settings.cleanup) { diff --git a/jquery.pretty-text-diff.min.js b/jquery.pretty-text-diff.min.js index 25e1691..9a09975 100644 --- a/jquery.pretty-text-diff.min.js +++ b/jquery.pretty-text-diff.min.js @@ -1,5 +1,5 @@ /* -@preserve jQuery.PrettyTextDiff 1.0.3 +@preserve jQuery.PrettyTextDiff 1.0.4 See https://github.com/arnab/jQuery.PrettyTextDiff/ -*/ -(function(){var $;$=jQuery;$.fn.extend({prettyTextDiff:function(options){var dmp,settings;settings={originalContainer:".original",changedContainer:".changed",diffContainer:".diff",cleanup:true,debug:false};settings=$.extend(settings,options);$.fn.prettyTextDiff.debug("Options: ",settings,settings);dmp=new diff_match_patch;return this.each(function(){var changed,diff_as_html,diffs,original;original=$(settings.originalContainer,this).text();$.fn.prettyTextDiff.debug("Original text found: ",original,settings);changed=$(settings.changedContainer,this).text();$.fn.prettyTextDiff.debug("Changed text found: ",changed,settings);diffs=dmp.diff_main(original,changed);if(settings.cleanup){dmp.diff_cleanupSemantic(diffs)}$.fn.prettyTextDiff.debug("Diffs: ",diffs,settings);diff_as_html=$.map(diffs,function(diff){return $.fn.prettyTextDiff.createHTML(diff)});$(settings.diffContainer,this).html(diff_as_html.join(""));return this})}});$.fn.prettyTextDiff.debug=function(message,object,settings){if(settings.debug){return console.log(message,object)}};$.fn.prettyTextDiff.createHTML=function(diff){var data,html,operation,pattern_amp,pattern_gt,pattern_lt,pattern_para,text;html=[];pattern_amp=/&/g;pattern_lt=//g;pattern_para=/\n/g;operation=diff[0],data=diff[1];text=data.replace(pattern_amp,"&").replace(pattern_lt,"<").replace(pattern_gt,">").replace(pattern_para,"
");switch(operation){case DIFF_INSERT:return""+text+"";case DIFF_DELETE:return""+text+"";case DIFF_EQUAL:return""+text+""}}}).call(this); \ No newline at end of file + */ +(function(){var $;$=jQuery;$.fn.extend({prettyTextDiff:function(options){var dmp,settings;settings={originalContainer:".original",changedContainer:".changed",diffContainer:".diff",cleanup:true,debug:false};settings=$.extend(settings,options);$.fn.prettyTextDiff.debug("Options: ",settings,settings);dmp=new diff_match_patch;return this.each(function(){var changed,diff_as_html,diffs,original;if(settings.originalContent&&settings.changedContent){original=$("
").html(settings.originalContent).text();changed=$("
").html(settings.changedContent).text()}else{original=$(settings.originalContainer,this).text();changed=$(settings.changedContainer,this).text()}$.fn.prettyTextDiff.debug("Original text found: ",original,settings);$.fn.prettyTextDiff.debug("Changed text found: ",changed,settings);diffs=dmp.diff_main(original,changed);if(settings.cleanup){dmp.diff_cleanupSemantic(diffs)}$.fn.prettyTextDiff.debug("Diffs: ",diffs,settings);diff_as_html=$.map(diffs,function(diff){return $.fn.prettyTextDiff.createHTML(diff)});$(settings.diffContainer,this).html(diff_as_html.join(""));return this})}});$.fn.prettyTextDiff.debug=function(message,object,settings){if(settings.debug){return console.log(message,object)}};$.fn.prettyTextDiff.createHTML=function(diff){var data,html,operation,pattern_amp,pattern_gt,pattern_lt,pattern_para,text;html=[];pattern_amp=/&/g;pattern_lt=//g;pattern_para=/\n/g;operation=diff[0],data=diff[1];text=data.replace(pattern_amp,"&").replace(pattern_lt,"<").replace(pattern_gt,">").replace(pattern_para,"
");switch(operation){case DIFF_INSERT:return""+text+"";case DIFF_DELETE:return""+text+"";case DIFF_EQUAL:return""+text+""}}}).call(this); \ No newline at end of file diff --git a/pretty-text-diff.jquery.json b/pretty-text-diff.jquery.json index b7a5913..1214ed1 100644 --- a/pretty-text-diff.jquery.json +++ b/pretty-text-diff.jquery.json @@ -1,6 +1,6 @@ { "name": "pretty-text-diff", - "version": "1.0.3", + "version": "1.0.4", "title": "jQuery.PrettyTextDiff", "description": "A jQuery plugin to show diff between text. Uses Google's diff_match_patch library underneath.", "keywords": [