-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwdiff-to-html.sh
executable file
·37 lines (31 loc) · 1011 Bytes
/
wdiff-to-html.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
if [ "$#" -ne 2 ]; then echo "Usage: sh wdiff-to-html.sh oldpaste newpaste"; echo "where arguments are from make-paste.sh"; exit 1; fi
WDIFFTMP=`mktemp -t wdiff.XXXXXXXXXX`;
dwdiff "$1" "$2" |\
sed "s%^S %<div class='src'>%g" |\
sed "s%^R %<div class='ref'>%g" |\
sed "s%^M %<div class='MT'>%g" |\
grep -v '^[ ]*$' |\
sed "s%^\([^<]\)%<div>\1%g" |\
sed "s%$%</div>%g" |\
sed "s%\(\[-[^-]*-\]\)%<span class='old'>\1</span>%g" |\
sed "s%\({+[^+]*+}\)%<span class='new'>\1$</span>%g" > $WDIFFTMP
cat <<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>word-diff -- FROM: _ ${1} _ TO: _ ${1} _</title>
<style type="text/css">
.old {color: blue;}
.new {color: red;}
.src {color: purple;}
.ref {color: green;}
.MT {margin-bottom: 1em;}
</style>
</head>
<body>
$(cat $WDIFFTMP)
</body>
</html>
EOF