angular-diff-match-patch
angular-diff-match-patch copied to clipboard
Support html encoded strings
It would be great if html encoded strings (ie. ≤ &ge
; etc.) would be supported (cfr. ng-bind-html)
Currently, the "raw" strings (≤ ≥
in stead of ≤ ≥) are shown within this library.
It does a straight text diff, so if your text includes ≤ it will show that or if you have encoding strings it will include those. Do you mean that you want it to do the diff and then also provide a way to encode/decode html strings? Or a way to diff encoded vs. decoded and know they are the same? I think both of those would fall slightly out of scope for what this does and should be handled via pre-processing of the string before doing the diff, but I'm willing to hear you out or accept a pull request.
Hi Adam,
Thanks for the quick reply and the awesome library!
What I'm looking for is a way to sanitize the "left" and "right" parts first and then do the diff. Ng-bind-html can be used, but <pre class="textdiff" diff left-obj="left" right-obj="right" ng-bind-html></pre>
doesn't make a difference.
Or should I try to use $sanitize in my controller so that instead of passing "left" as left-obj, a $sanitize(left) statement is used (and the same for the right part)?
Maybe the $sanitize behavior can be incorporated in your library?
Thanks for clarifying. At this point, I really just maintain this library and accept pull requests. Getting $sanitize
embedded is a bit beyond what I have time to do right now. I tried doing the $sanitize
in the controller before doing the diff and it does work fine, so I would suggest going that route if you need to sanitize something before the diff.
I'll leave this open for how if you or someone else wants to provide a pull request for this, but as of right now I don't plan to add it.