gitweb: highlight: replace tabs with spaces
PATCH 1/1 gitweb: highlight: replace tabs with spaces
Consider the following code fragment:
/*
* test
*/vim ":set list" mode shows that the first character on each line is a tab:
^I/*$
^I * test$
^I */$
By default, the "highlight" program will retain the tabs in the HTML output:
$ highlight --fragment --syntax c test.c
<span class="hl com">/*</span>
<span class="hl com"> * test</span>
<span class="hl com"> */</span>vim list mode:
^I<span class="hl com">/*</span>$
<span class="hl com">^I * test</span>$
<span class="hl com">^I */</span>$
In gitweb, this winds up looking something like:
1 /*
2 * test
3 */
I tried both Firefox and Opera and saw the same behavior.
The desired output is:
1 /*
2 * test
3 */
This can be accomplished by specifying "--replace-tabs=8" on the highlight command line.
--- gitweb/gitweb.perl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +1 -1
@@ -3485,7 +3485,7 @@ sub run_highlighter { close $fd; open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ". quote_command($highlight_bin). - " --fragment --syntax $syntax |" + " --replace-tabs=8 --fragment --syntax $syntax |" or die_error(500, "Couldn't open file or run syntax highlighter"); return $fd; }
Signature · 1 line
1.7.4.1
Quoted 54 lines · Kevin Cernekee
Consider the following code fragment:
/* * test */vim ":set list" mode shows that the first character on each line is a tab:
^I/*$
^I * test$
^I */$By default, the "highlight" program will retain the tabs in the HTML output:
$ highlight --fragment --syntax c test.c <span class="hl com">/*</span> <span class="hl com"> * test</span> <span class="hl com"> */</span>vim list mode:
^I<span class="hl com">/*</span>$
<span class="hl com">^I * test</span>$
<span class="hl com">^I */</span>$In gitweb, this winds up looking something like:
1 /*
2 * test
3 */I tried both Firefox and Opera and saw the same behavior.
The desired output is:
1 /*
2 * test
3 */This can be accomplished by specifying "--replace-tabs=8" on the highlight command line.
Signed-off-by Kevin Cernekee <[email protected]>--- gitweb/gitweb.perl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)gitweb/gitweb.perl +0
-0
gitweb/gitweb.perl sub run_highlighter { · line 3491
Quoted 8 lines
gitweb/gitweb.perl +1
-1@@ -3485,7 +3485,7 @@ sub run_highlighter { close $fd; open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ". quote_command($highlight_bin). - " --fragment --syntax $syntax |" + " --replace-tabs=8 --fragment --syntax $syntax |" or die_error(500, "Couldn't open file or run syntax highlighter"); return $fd; }
Looks fine to me.
- John 'Warthog9' Hawley
Quoted 35 lines · Kevin Cernekee
Consider the following code fragment:
/* * test */vim ":set list" mode shows that the first character on each line is a tab:
^I/*$
^I * test$
^I */$By default, the "highlight" program will retain the tabs in the HTML output:
$ highlight --fragment --syntax c test.c <span class="hl com">/*</span> <span class="hl com"> * test</span> <span class="hl com"> */</span>vim list mode:
^I<span class="hl com">/*</span>$
<span class="hl com">^I * test</span>$
<span class="hl com">^I */</span>$In gitweb, this winds up looking something like:
1 /*
2 * test
3 */I tried both Firefox and Opera and saw the same behavior.
Quoted 8 lines
The desired output is:
1 /*
2 * test
3 */This can be accomplished by specifying "--replace-tabs=8" on the highlight command line.
Very well written commit message.
Quoted 1 line
Signed-off-by Kevin Cernekee <[email protected]>
I was wondering if ancient highlight (2.4.5) that I use supports --replace-tabs option... but it does.
So for what it is worth:
Quoted 9 lines
--- gitweb/gitweb.perl | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)gitweb/gitweb.perl +0
-0
gitweb/gitweb.perl sub run_highlighter { · line 3491
Quoted 8 lines
gitweb/gitweb.perl +1
-1@@ -3485,7 +3485,7 @@ sub run_highlighter { close $fd; open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ". quote_command($highlight_bin). - " --fragment --syntax $syntax |" + " --replace-tabs=8 --fragment --syntax $syntax |" or die_error(500, "Couldn't open file or run syntax highlighter"); return $fd; }
I wonder if we should synchronize this value with '8' in untabify(), but I think it is out of scope of this patch.
BTW., weren't there patch that made tab width customizable? What happened to it?
Signature · 3 lines
Jakub Narebski Poland ShadeHawk on #git