Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

rjbs (4671)

  (email not shown publicly)
AOL IM: RicardoJBSignes (Add Buddy, Send Message)
Yahoo! ID: RicardoSignes (Add User, Send Message)

I'm a Perl coder living in Bethlehem, PA and working Philadelphia. I'm a philosopher and theologan by training, but I was shocked to learn upon my graduation that these skills don't have many associated careers. Now I write code.

Journal of rjbs (4671)

Wednesday September 05, 2007
09:24 AM

progress with syntax-to-rtf

[ #34355 ]

I had really wanted to use the Kate syntax stuff, because it's pure Perl, but after I had it working, I decided that its Perl syntax highlighting wasn't good enough, and I wanted Vim's. So, I did what I had wanted to avoid and used Text::VimColor. I worked out some bugs, learned a lot about RTF, and added nice little things like proper option parsing.

I put it on my hacks page, along with a sample output file. Reading the RTF::Writer source with a clearer head made the problem I'd had with dashes clear. (It also makes me think that RTF::Writer needs to stop doing what it's doing.)

There's just one big thing bugging me, now. I can't find a way to change the background color of the document, which I think will have to be done with a default stylesheet or something. I'd create a file with a black background to inspect its contents, but I don't even see how to do that in TextEdit.

With a white background, the margins are white, and extra whitespace at the end of the file is white. I really want to be able to set the default background, to address this problem correctly.

Next up, I may attempt to write a very crude Vim colorscheme parser. With that done, it just becomes a matter of automating the highlighting of text in a Keynote text box.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • You could use Syntax::Highlight::Universal (it needs a patch from RT to help it compile). If you just have it tokenize and create the HTML from it, it's simply elements with classes. Then you can control every detail of the color using CSS.

    I've done this before for with a Spork plugin that would let me easily wrap my code samples with something like .syntax perl
    or .syntax html

    It was really useful when I give multi language talks (Perl/JavaScript/HTML/CSS).

    I never put my plugin up on CPAN or into SVN, so whe
    • I don't get it. How can CSS help me produce color RTF?
      • Well, I feel silly. For some reason I thought you were doing syntax hilighting into HTML and then converting to RTF. But you're using RTF::Writer, duh. Sorry for the noise...
        • No problem. If nothing else, now I know I can look at one more highlighting engine eventually! Thanks.
  • Is VIM's colorizing better than PerlTidy's for your purpose?
    # I had a sig when sigs were cool
    use Sig;
    • I haven't tried it, but I'm guessing it will be -- only because it will be exactly what I'm used to seeing in my editor.

      I'll try to check it out.
      • PerlTidy is adjustable.

        The Perl Advent Calendar [] uses perltidy -nnn -html -css=../style.css [* [] * []] so the CSS file sets the colors.

        You could edit that file to get the VIM look with PerlTidy. PerlTidy can also adapt its indenting etc. to suit most standards. E.g., I think PBP has Tidy definition of it's recommended format. Spod5 [] is a perl-based pod-to-S5 slide systm that can filter code through perltidy.

        # I had a sig when sigs were cool
        use Sig;