in reply to printing source code green bar style

You could expand tabs to spaces (using Text::Tabs, f.ex) and then convert all spaces to  /  entities.

I was pretty sure a2ps would have an option for this, but it doesn't appear to. Bummer…

Makeshifts last the longest.

  • Comment on Re: printing source code green bar style

Replies are listed 'Best First'.
Re^2: printing source code green bar style
by BlndCat (Initiate) on Sep 17, 2004 at 16:15 UTC
    I've been thinking along those lines but I am not sure how it would wrap after all the spaces have been changed to  

    another problem is that for a short line, the stripes won't run to the end but rather just to the length of text present on that line. maybe outputing to pdf while more complicated would be less of a hack. no idea of how to do it in perl though

    I've been searching the web and it seems strange that no-one has tackled this before. I do remember a html editor once had that option. maybe webedit?

      I don't think it's particularly strange given how trivial it is. Use CSS instead of a table and stick the lines in some block-level element. A stylesheet like this should be all you need:

      p.even, p.odd { margin: 0; padding: 0.2em; } p.odd { background-color: #ccc; }

      And then you stick the lines in

      <p class="even">#!/usr/bin/perl</p> <p class="odd">use&#160;strict;</p> <p class="even">use&#160;warnings;</p> <p class="odd"></p> <p class="even">BEGIN&#160;{</p> <p class="odd">&#160;&#160;&#160;&#160;$|&#160;=&#160;1;</p> <p class="even">}</p> ...

      Makeshifts last the longest.

        I think Aristotle's solution is the best (there's no way you'll get a laser printer to line up correctly on pre-lined paper without wasting lots o'paper). Here's a one liner to do what he suggests.

        perl -MCGI -lp -e '$_ = CGI::p({-class=> $c++ % 2 ? 'even':'odd'}, $_ )' [file list]