public String diff_prettyHtml ( LinkedList < Diff > diffs ) { StringBuilder html = new StringBuilder ( ) ; for ( Diff aDiff : diffs ) { String text = aDiff . text . replace ( "&" , "&amp;" ) . replace ( "<" , "&lt;" ) . replace ( ">" , "&gt;" ) . replace ( "\n" , "&para;<br>" ) ; switch ( aDiff . operation ) { case INSERT : html . append ( "<ins style=\"background:#e6ffe6;\">" ) . append ( text ) . append ( "</ins>" ) ; break ; case DELETE : html . append ( "<del style=\"background:#ffe6e6;\">" ) . append ( text ) . append ( "</del>" ) ; break ; case EQUAL : html . append ( "<span>" ) . append ( text ) . append ( "</span>" ) ; break ; } } return html . toString ( ) ; }
Convert a Diff list into a pretty HTML report .