diff_prettyHtml method
Convert a Diff list into a pretty HTML report.
diffs
is a List of Diff objects.
Returns an HTML representation.
Implementation
String diff_prettyHtml(List<Diff> diffs) {
final html = StringBuffer();
for (Diff aDiff in diffs) {
String text = aDiff.text
.replaceAll('&', '&')
.replaceAll('<', '<')
.replaceAll('>', '>')
.replaceAll('\n', '<br>');
switch (aDiff.operation) {
case Operation.insert:
html.write('<ins>');
html.write(text);
html.write('</ins>');
break;
case Operation.delete:
html.write('<del>');
html.write(text);
html.write('</del>');
break;
case Operation.equal:
html.write('<span>');
html.write(text);
html.write('</span>');
break;
}
}
return html.toString();
}