Stories
Slash Boxes
Comments
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 ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Monday October 26, 2009
06:20 PM

Syntax Highlighting in Pod::Parser::Groffmom

[ #39803 ]

I decided that I really needed syntax highlighting in Pod::Parser::Groffman. I have an example at Testing with Test::Class. Note that the Perl examples are now colored. It's not what everyone would like, but it works.

To handle syntax highlighting, you just do this:

=for highlight Perl

  sub add {
      my ( $self, $data ) = @_;
      my $add = $self->in_list_mode ? 'add_to_list' : 'add_to_mom';
      $self->$add($data);
  }

=end highlight

This turns on syntax highlighting. Allowable highlight types are the types allowed for Syntax::Highlight::Engine::Kate. We default to Perl, so the above can be written as:

=for highlight

  sub add {
      my ( $self, $data ) = @_;
      my $add = $self->in_list_mode ? 'add_to_list' : 'add_to_mom';
      $self->$add($data);
  }

=end highlight

Syntax highlighting is experimental and a bit flaky. Some lines after comments are highlighted as comments. Also, POD in verbatim (indented) POD highlights incorrectly. Common_Lisp is allegedly supported by Syntax::Highlight::Engine::Kate, but I was getting weird stack errors when I tried to highlight it.

Also, don't use angle brackets with quote operators like "q" or "qq". The highlighter gets confused. I've not filed any bug reports as I've no idea if the errors are mine or the syntax highlighting module.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.