Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'd like to use Movable Type as a content management system.

Is there any way to highlight Perl code in MT?.

Example:

Some HTML and/or text goes here <code perl> #!/usr/bin/perl use warnings; use strict; # More code here </ code> Some more HTML and/or text goes here

I want a syntax highlighting for the "code" part. The rest shoud stay untouched.

Thanks.

Replies are listed 'Best First'.
Re: Movable Type: Highlighting Perl Code
by amarquis (Curate) on Apr 08, 2008 at 16:37 UTC

    http://plugins.movabletype.org/mt-colorer/, a syntax highlighter MT plugin (never used, just found via search).

    Edit: I just read farther into the MT-Colorer page, and it requires Syntax::Highlight::Universal, which I'm guessing is difficult to get on most shared hosting platforms.

Re: Movable Type: Highlighting Perl Code
by jasonk (Parson) on Apr 11, 2008 at 00:12 UTC

    I just started using Movable Type this week, and went through the same search, but didn't find anything that worked the way I wanted. So I ended up writing a plugin to do text formatting using my Text::Multi module. It may not work for you as-is, but it's short enough that it could get you started writing a plugin that does work just the way you want it...

    # JasonKohles::TextMulti plugin # Copyright 2008 Jason Kohles # <email@jasonkohles.com> # http://www.jasonkohles.com/ # package JasonKohles::TextMulti; use strict; use warnings; our $VERSION = '0.1'; our $ID = '$Id$'; use base qw( MT::Plugin ); use Text::Multi; MT->add_plugin( __PACKAGE__->new( { id => 'textmulti', name => 'TextMulti', version => $VERSION, author_name => 'Jason Kohles', author_link => 'http://www.jasonkohles.com/', plugin_link => 'http://code.jasonkohles.com/MTTextMulti/', doc_link => 'docs.html', description => 'Text::Multi Format Filter', registry => { text_filters => { text_multi => { label => 'Text::Multi', docs => 'docs.html', code => sub { my $parser = Text::Multi->new( default_type => 'Markdown' ); $parser->process_text( $_[0] ); return $parser->render; }, }, }, }, } ) );

    We're not surrounded, we're in a target-rich environment!
Re: Movable Type: Highlighting Perl Code
by oko1 (Deacon) on Apr 08, 2008 at 19:40 UTC

    Erm... whoops, I somehow posted in the wrong thread. Never mind. :)

    
    -- 
    Human history becomes more and more a race between education and catastrophe. -- HG Wells
    
Re: Movable Type: Highlighting Perl Code
by wazoox (Prior) on Apr 09, 2008 at 16:54 UTC
    What about using javascript for this? There is this stuff I use on perlmonks (sorry I don't remember whom it comes from):
    <script> var headID = document.getElementsByTagName("head")`[0`]; var cssNode = document.createElement('link'); cssNode.type = 'text/css'; cssNode.rel = 'stylesheet'; cssNode.href = 'http://datenzoo.de/pub/prettify.css'; cssNode.media = 'screen'; headID.appendChild(cssNode); </script> <script type="text/javascript" src="http://datenzoo.de/pub/prettify.js +"></script> <script> prettyPrint(); </script>
    It's really nice! Paste it in your perlmonks free nodelet to try it.
        Thanks, I should add this in an HTML comment in my free nodelet to remember that :)