#!/usr/bin/perl
MAIN: {
my
%opts
= ();
GetOptions(\
%opts
,
@SGML::DTDParse::CommonOptions
) || SGML::DTDParse::usage(
-verbose
=> 0,
-exitval
=> 1);
SGML::DTDParse::process_common_options(\
%opts
);
print
<<EOT;
<html>
<head>
<title>Diff</title>
<style type="text/css">
body {
background-color: #DDDDDD;
}
pre.contextDiff {
background: #EEEEEE;
border-color: black;
border-style: solid;
border-width: thin;
padding: 0.25em;
}
.diffDel {
color: red;
}
.diffAdd {
color: green;
}
.diffChng {
color: blue;
}
</style>
</head>
<body>
<pre class="contextDiff">
EOT
my
$in_chng
= 0;
while
(<>) {
chomp
;
if
(/^[!]/) {
if
(/::=/) {
print
'<span class="diffChng">'
, entify(
$_
),
"\n"
;
$in_chng
= 1;
next
;
}
else
{
print
'<span class="diffChng">'
, entify(
$_
),
"</span>\n"
;
next
;
}
}
if
(/^(---|[*+\-])/) {
if
(
$in_chng
) {
print
"</span>"
;
$in_chng
= 0;
}
elsif
($1 eq
'---'
|| $1 eq
'*'
) {
print
'<b>'
, entify(
$_
),
"</b>\n"
;
}
elsif
($1 eq
'+'
) {
print
'<span class="diffAdd">'
, entify(
$_
),
"</span>\n"
;
}
elsif
($1 eq
'-'
) {
print
'<span class="diffDel">'
, entify(
$_
),
"</span>\n"
;
}
next
;
}
if
(
$in_chng
&& !/\S/) {
print
"</span>"
;
$in_chng
= 0;
}
print
entify(
$_
),
"\n"
;
}
print
qq{</pre>\n}
;
}
sub
entify {
my
$txt
=
shift
;
$txt
=~ s/&/
&
;/g;
$txt
=~ s/</
<
;/g;
$txt
=~ s/>/
>
;/g;
$txt
;
}