summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 241cc59)
raw | patch | inline | side by side (parent: 241cc59)
author | Jakub Narebski <jnareb@gmail.com> | |
Wed, 1 Nov 2006 13:33:21 +0000 (14:33 +0100) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 3 Nov 2006 07:13:37 +0000 (23:13 -0800) |
Add option to replace SPC (' ') with hard (non-breakable) space HTML
entity ' ' in esc_html subroutine.
Replace ' ' with ' ' for the code/diff display part in git_blob
and git_patchset_body; this is to be able to view code and diffs in
web browsers which doesn't understand "white-space: pre;" CSS
declaration.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
entity ' ' in esc_html subroutine.
Replace ' ' with ' ' for the code/diff display part in git_blob
and git_patchset_body; this is to be able to view code and diffs in
web browsers which doesn't understand "white-space: pre;" CSS
declaration.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
gitweb/gitweb.perl | patch | blob | history |
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index dfb15c1ef9e56e28c131fcde4eceb19f19a9ad41..3dfa59f616c78cea8147e58aee1accde68c58046 100755 (executable)
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
}
# replace invalid utf8 character with SUBSTITUTION sequence
-sub esc_html {
+sub esc_html ($;%) {
my $str = shift;
+ my %opts = @_;
+
$str = to_utf8($str);
$str = escapeHTML($str);
$str =~ s/\014/^L/g; # escape FORM FEED (FF) character (e.g. in COPYING file)
$str =~ s/\033/^[/g; # "escape" ESCAPE (\e) character (e.g. commit 20a3847d8a5032ce41f90dcc68abfb36e6fee9b1)
+ if ($opts{'-nbsp'}) {
+ $str =~ s/ / /g;
+ }
return $str;
}
$diff_class = " incomplete";
}
$line = untabify($line);
- return "<div class=\"diff$diff_class\">" . esc_html($line) . "</div>\n";
+ return "<div class=\"diff$diff_class\">" . esc_html($line, -nbsp=>1) . "</div>\n";
}
## ----------------------------------------------------------------------
$nr++;
$line = untabify($line);
printf "<div class=\"pre\"><a id=\"l%i\" href=\"#l%i\" class=\"linenr\">%4i</a> %s</div>\n",
- $nr, $nr, $nr, esc_html($line);
+ $nr, $nr, $nr, esc_html($line, -nbsp=>1);
}
close $fd
or print "Reading blob failed.\n";