From ccc374ecd0eafd67e73b80201eb1c451700c106a Mon Sep 17 00:00:00 2001 From: Jonas Smedegaard Date: Sun, 21 Apr 2013 15:30:38 +0200 Subject: Add Word diff script. --- localworddiff | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 localworddiff (limited to 'localworddiff') diff --git a/localworddiff b/localworddiff new file mode 100755 index 0000000..a1ec03a --- /dev/null +++ b/localworddiff @@ -0,0 +1,67 @@ +#!/bin/sh +# +# Copyright © 2013 Jonas Smedegaard +# Description: Generate word-based diff for console or web +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Depends: libtext-worddiff-perl (>= 0.08) +# +# TODO: rewrite as Perl script, using HTML::HTML5::Builder + +set -e + +if [ -z "$3" ]; then + perl -MText::WordDiff -E 'say word_diff "'"$1"'", "'"$2"'", { STYLE => 'ANSIColor' }' + exit +fi + +cat > "$3" < + + + + + + +EOF +perl -MText::WordDiff -E 'say word_diff "'"$1"'", "'"$2"'", { STYLE => 'HTMLTwoLines' }' >> "$3" +cat >> "$3" < + +EOF -- cgit v1.2.3