blob: 1c4077afab1d2c2f8a0bcaa336e156e3607857dc (
plain)
- #!/bin/sh
- #
- # Copyright © 2013 Jonas Smedegaard <dr@jones.dk>
- # 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 <http://www.gnu.org/licenses/>.
- #
- # 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
- <!DOCTYPE html>
- <html>
- <head>
- <style>
- .fileheader {
- display: none;
- visibility: hidden;
- }
- .file {
- float: left;
- width: 49%;
- }
- .file .hunk {
- float: right;
- width: 90%;
- }
- .file .hunk del,
- .file .hunk ins {
- font-weight: bold;
- }
- .file .hunk del {
- color: darkred;
- }
- .file .hunk ins {
- color: darkgreen;
- }
- </style>
- </head>
- <body>
- EOF
- perl -MText::WordDiff -E 'say word_diff "'"$1"'", "'"$2"'", { STYLE => 'HTMLTwoLines' }' >> "$3"
- cat >> "$3" <<EOF
- </body>
- </html>
- EOF
|