* [PATCH] gitweb: highlight: replace tabs with spaces
@ 2011-03-16 22:34 Kevin Cernekee
2011-03-16 22:48 ` J.H.
2011-03-17 10:04 ` Jakub Narebski
0 siblings, 2 replies; 3+ messages in thread
From: Kevin Cernekee @ 2011-03-16 22:34 UTC (permalink / raw)
To: git
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 <cernekee@gmail.com>
---
gitweb/gitweb.perl | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d171ad5..649e10a 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -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;
}
--
1.7.4.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gitweb: highlight: replace tabs with spaces
2011-03-16 22:34 [PATCH] gitweb: highlight: replace tabs with spaces Kevin Cernekee
@ 2011-03-16 22:48 ` J.H.
2011-03-17 10:04 ` Jakub Narebski
1 sibling, 0 replies; 3+ messages in thread
From: J.H. @ 2011-03-16 22:48 UTC (permalink / raw)
To: Kevin Cernekee; +Cc: git
On 03/16/2011 03:34 PM, Kevin Cernekee wrote:
> 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 <cernekee@gmail.com>
> ---
> gitweb/gitweb.perl | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index d171ad5..649e10a 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gitweb: highlight: replace tabs with spaces
2011-03-16 22:34 [PATCH] gitweb: highlight: replace tabs with spaces Kevin Cernekee
2011-03-16 22:48 ` J.H.
@ 2011-03-17 10:04 ` Jakub Narebski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Narebski @ 2011-03-17 10:04 UTC (permalink / raw)
To: Kevin Cernekee; +Cc: git
Kevin Cernekee <cernekee@gmail.com> writes:
> 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.
Very well written commit message.
> Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
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:
Acked-by: Jakub Narebski <jnareb@gmail.com>
> ---
> gitweb/gitweb.perl | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index d171ad5..649e10a 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -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?
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-03-17 10:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-16 22:34 [PATCH] gitweb: highlight: replace tabs with spaces Kevin Cernekee
2011-03-16 22:48 ` J.H.
2011-03-17 10:04 ` Jakub Narebski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).