{"thread":{"id":"26757","subject":"[PATCH] gitweb: highlight: replace tabs with spaces","startedAt":"2011-03-16T22:34:13Z","lastAt":"2011-03-17T10:04:15Z","messageCount":3,"participants":["Kevin Cernekee","J.H.","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"163522","messageId":"6ac7d48cfdf4192c3240c1ecbd4e5522@localhost","threadId":"26757","inReplyTo":null,"subject":"[PATCH] gitweb: highlight: replace tabs with spaces","fromName":"Kevin Cernekee","fromEmail":"cernekee@gmail.com","sentAt":"2011-03-16T22:34:13Z","receivedAt":"2011-03-16T22:34:13Z","isPatch":true,"sender":{"key":"cernekee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1631864?v=4"},"body":"Consider the following code fragment:\n\n        /*\n         * test\n         */\n\nvim \":set list\" mode shows that the first character on each line is a\ntab:\n\n^I/*$\n^I * test$\n^I */$\n\nBy default, the \"highlight\" program will retain the tabs in the HTML\noutput:\n\n$ highlight --fragment --syntax c test.c\n        <span class=\"hl com\">/*</span>\n<span class=\"hl com\">    * test</span>\n<span class=\"hl com\">    */</span>\n\nvim list mode:\n\n^I<span class=\"hl com\">/*</span>$\n<span class=\"hl com\">^I * test</span>$\n<span class=\"hl com\">^I */</span>$\n\nIn gitweb, this winds up looking something like:\n\n   1         /*\n   2     * test\n   3     */\n\nI tried both Firefox and Opera and saw the same behavior.\n\nThe desired output is:\n\n   1         /*\n   2          * test\n   3          */\n\nThis can be accomplished by specifying \"--replace-tabs=8\" on the\nhighlight command line.\n\nSigned-off-by: Kevin Cernekee <cernekee@gmail.com>\n---\n gitweb/gitweb.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\nindex d171ad5..649e10a 100755\n--- a/gitweb/gitweb.perl\n+++ b/gitweb/gitweb.perl\n@@ -3485,7 +3485,7 @@ sub run_highlighter {\n \tclose $fd;\n \topen $fd, quote_command(git_cmd(), \"cat-file\", \"blob\", $hash).\" | \".\n \t          quote_command($highlight_bin).\n-\t          \" --fragment --syntax $syntax |\"\n+\t          \" --replace-tabs=8 --fragment --syntax $syntax |\"\n \t\tor die_error(500, \"Couldn't open file or run syntax highlighter\");\n \treturn $fd;\n }\n-- \n1.7.4.1\n"},{"id":"163523","messageId":"4D813E4F.1030304@eaglescrag.net","threadId":"26757","inReplyTo":"6ac7d48cfdf4192c3240c1ecbd4e5522@localhost","subject":"Re: [PATCH] gitweb: highlight: replace tabs with spaces","fromName":"J.H.","fromEmail":"warthog9@eaglescrag.net","sentAt":"2011-03-16T22:48:47Z","receivedAt":"2011-03-16T22:48:47Z","isPatch":true,"sender":{"key":"warthog9@kernel.org","avatar":"https://avatars.githubusercontent.com/u/2334704?v=4"},"body":"On 03/16/2011 03:34 PM, Kevin Cernekee wrote:\n> Consider the following code fragment:\n> \n>         /*\n>          * test\n>          */\n> \n> vim \":set list\" mode shows that the first character on each line is a\n> tab:\n> \n> ^I/*$\n> ^I * test$\n> ^I */$\n> \n> By default, the \"highlight\" program will retain the tabs in the HTML\n> output:\n> \n> $ highlight --fragment --syntax c test.c\n>         <span class=\"hl com\">/*</span>\n> <span class=\"hl com\">    * test</span>\n> <span class=\"hl com\">    */</span>\n> \n> vim list mode:\n> \n> ^I<span class=\"hl com\">/*</span>$\n> <span class=\"hl com\">^I * test</span>$\n> <span class=\"hl com\">^I */</span>$\n> \n> In gitweb, this winds up looking something like:\n> \n>    1         /*\n>    2     * test\n>    3     */\n> \n> I tried both Firefox and Opera and saw the same behavior.\n> \n> The desired output is:\n> \n>    1         /*\n>    2          * test\n>    3          */\n> \n> This can be accomplished by specifying \"--replace-tabs=8\" on the\n> highlight command line.\n> \n> Signed-off-by: Kevin Cernekee <cernekee@gmail.com>\n> ---\n>  gitweb/gitweb.perl |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index d171ad5..649e10a 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -3485,7 +3485,7 @@ sub run_highlighter {\n>  \tclose $fd;\n>  \topen $fd, quote_command(git_cmd(), \"cat-file\", \"blob\", $hash).\" | \".\n>  \t          quote_command($highlight_bin).\n> -\t          \" --fragment --syntax $syntax |\"\n> +\t          \" --replace-tabs=8 --fragment --syntax $syntax |\"\n>  \t\tor die_error(500, \"Couldn't open file or run syntax highlighter\");\n>  \treturn $fd;\n>  }\n\nLooks fine to me.\n\n- John 'Warthog9' Hawley\n"},{"id":"163546","messageId":"m3pqpq5aiv.fsf@localhost.localdomain","threadId":"26757","inReplyTo":"6ac7d48cfdf4192c3240c1ecbd4e5522@localhost","subject":"Re: [PATCH] gitweb: highlight: replace tabs with spaces","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2011-03-17T10:04:15Z","receivedAt":"2011-03-17T10:04:15Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Kevin Cernekee <cernekee@gmail.com> writes:\n\n> Consider the following code fragment:\n> \n>         /*\n>          * test\n>          */\n> \n> vim \":set list\" mode shows that the first character on each line is a\n> tab:\n> \n> ^I/*$\n> ^I * test$\n> ^I */$\n> \n> By default, the \"highlight\" program will retain the tabs in the HTML\n> output:\n> \n> $ highlight --fragment --syntax c test.c\n>         <span class=\"hl com\">/*</span>\n> <span class=\"hl com\">    * test</span>\n> <span class=\"hl com\">    */</span>\n> \n> vim list mode:\n> \n> ^I<span class=\"hl com\">/*</span>$\n> <span class=\"hl com\">^I * test</span>$\n> <span class=\"hl com\">^I */</span>$\n> \n> In gitweb, this winds up looking something like:\n> \n>    1         /*\n>    2     * test\n>    3     */\n> \n> I tried both Firefox and Opera and saw the same behavior.\n> \n> The desired output is:\n> \n>    1         /*\n>    2          * test\n>    3          */\n> \n> This can be accomplished by specifying \"--replace-tabs=8\" on the\n> highlight command line.\n\nVery well written commit message.\n\n> Signed-off-by: Kevin Cernekee <cernekee@gmail.com>\n\nI was wondering if ancient highlight (2.4.5) that I use supports\n--replace-tabs option... but it does.\n\nSo for what it is worth:\n\nAcked-by: Jakub Narebski <jnareb@gmail.com>\n\n> ---\n>  gitweb/gitweb.perl |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n> \n> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl\n> index d171ad5..649e10a 100755\n> --- a/gitweb/gitweb.perl\n> +++ b/gitweb/gitweb.perl\n> @@ -3485,7 +3485,7 @@ sub run_highlighter {\n>  \tclose $fd;\n>  \topen $fd, quote_command(git_cmd(), \"cat-file\", \"blob\", $hash).\" | \".\n>  \t          quote_command($highlight_bin).\n> -\t          \" --fragment --syntax $syntax |\"\n> +\t          \" --replace-tabs=8 --fragment --syntax $syntax |\"\n>  \t\tor die_error(500, \"Couldn't open file or run syntax highlighter\");\n>  \treturn $fd;\n>  }\n\nI wonder if we should synchronize this value with '8' in untabify(),\nbut I think it is out of scope of this patch.\n\nBTW., weren't there patch that made tab width customizable?  What\nhappened to it?\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}