commit 4678ce1b685390349c692323d9c2c819838e9054
Author: spesk1 <spesk@pm.me>
Date: Sat Jun 22 19:44:02 2019 +0000
Worked around diff html issue via xmp HTML tags. Probably a better way to do this
diff --git a/README.md b/README.md
index 3c43c5b..7ef4471 100644
--- a/README.md
+++ b/README.md
@@ -20,7 +20,6 @@ TODO:
* Show git:// address for cloning (configurable via config file)
* Code needs to be more robust / handle failure cases
* Need to recurse git home, right now will only pull dirs in root of git home
-* Fix issue with diff highlight where if the diff contains HTML it gets rendered in the browser (isolate/sanitize it somehow)
* README.md markdown renderer/parser / display in project index
* (Stretch Goal) HTML based syntax highlighting for files
* Support detection of misconfig of config file
diff --git a/lib/Gsg/Html.pm b/lib/Gsg/Html.pm
index ffad1d1..24486de 100644
--- a/lib/Gsg/Html.pm
+++ b/lib/Gsg/Html.pm
@@ -86,17 +86,22 @@ sub gen_diff_colors($$) {
my $html_diff;
open my $fh, '>>', \$html_diff or die "Can't open variable: $!";
- print $fh "<!DOCTYPE html><html><div id=\"content\"><pre id=\"blob\">";
+ #print $fh "<!DOCTYPE html><html><div id=\"content\"><pre id=\"blob\">";
+ print $fh "<!DOCTYPE html><html><div id=\"content\"><pre>";
my $line_counter = 1;
foreach my $line ( split("\n", $raw_diff) ) {
if ( $line =~ m/^\+/ ) {
- print $fh "<a href=\"\#l$line_counter\" class=\"line\" id=\"l$line_counter\">$line_counter</a><font color=\"green\">\t$line</font></br>";
+ print $fh "<font color=\"green\"><xmp>$line</xmp></font>";
} elsif ( $line =~ m/^\-/ ) {
- print $fh "<a href=\"\#l$line_counter\" class=\"line\" id=\"l$line_counter\">$line_counter</a><font color=\"red\">\t$line</font></br>";
+ print $fh "<font color=\"red\"><xmp>$line</xmp></font>";
} elsif ( $line =~ m/^@@/ ) {
- print $fh "<a href=\"\#l$line_counter\" class=\"line\" id=\"l$line_counter\">$line_counter</a><font color=\"blue\">\t$line</font></br>";
+ print $fh "<font color=\"blue\"><xmp>$line</xmp></font>";
+ } elsif ( $line =~ m/^diff/ ) {
+ print $fh "<font color=\"purple\"><xmp>$line</xmp></font>";
+ } elsif ( $line =~ m/^commit/ ) {
+ print $fh "<font color=\"purple\"><b><xmp>$line</xmp></b></font>";
} else {
- print $fh "<a href=\"\#l$line_counter\" class=\"line\" id=\"l$line_counter\">$line_counter</a>\t$line</br>";
+ print $fh "<xmp>$line</xmp>";
}
$line_counter++;
}