angular-diff-match-patch icon indicating copy to clipboard operation
angular-diff-match-patch copied to clipboard

Support html encoded strings

Open RubenDelange opened this issue 6 years ago • 3 comments

It would be great if html encoded strings (ie. ≤ ≥ etc.) would be supported (cfr. ng-bind-html)

Currently, the "raw" strings (≤ ≥ in stead of ≤ ≥) are shown within this library.

RubenDelange avatar Apr 25 '18 08:04 RubenDelange

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.

angular-diff-match-patch

amweiss avatar Apr 25 '18 13:04 amweiss

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?

RubenDelange avatar Apr 26 '18 07:04 RubenDelange

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.

amweiss avatar Apr 26 '18 13:04 amweiss