Convert a Diff list into a pretty HTML report. @param diffs LinkedList of Diff objects. @return HTML representation.
(LinkedList<Diff> diffs)
| 1356 | * @return HTML representation. |
| 1357 | */ |
| 1358 | public String diff_prettyHtml(LinkedList<Diff> diffs) { |
| 1359 | StringBuilder html = new StringBuilder(); |
| 1360 | for (Diff aDiff : diffs) { |
| 1361 | String text = aDiff.text.replace("&", "&").replace("<", "<") |
| 1362 | .replace(">", ">").replace("\n", "¶<br>"); |
| 1363 | switch (aDiff.operation) { |
| 1364 | case INSERT: |
| 1365 | html.append("<ins style=\"background:#e6ffe6;\">").append(text) |
| 1366 | .append("</ins>"); |
| 1367 | break; |
| 1368 | case DELETE: |
| 1369 | html.append("<del style=\"background:#ffe6e6;\">").append(text) |
| 1370 | .append("</del>"); |
| 1371 | break; |
| 1372 | case EQUAL: |
| 1373 | html.append("<span>").append(text).append("</span>"); |
| 1374 | break; |
| 1375 | } |
| 1376 | } |
| 1377 | return html.toString(); |
| 1378 | } |
| 1379 | |
| 1380 | /** |
| 1381 | * Compute and return the source text (all equalities and deletions). |