Re: [PATCH] gitweb: highlight: replace tabs with spaces

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
> ---
>  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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]