Search code examples
perlsyntax-highlighting

Is there a Perl Syntax Highlighter (outputting to HTML) like PHP's GeSHi?


Most PHP Developers are likely familar with the Syntax Highlighter called "GeSHi", which takes code, highlights it, with the use of HTML and CSS:

include('geshi.php');
$source = 'echo "hello, world!";
$language = 'php';
$path = 'geshi/';
$geshi = new GeSHi($source, $language, $path);
echo $geshi->parse_code();

GeSHi Supports a wide range of languages.

I wonder, is there a similar Module for Perl?


Solution

    1. Perl has a port of Kate highlighting system: Syntax::Highlight::Engine::Kate which seems to be somewhat close to what you need. It appears to be part of Padre.

    2. You also have an option of HTML client side highlighters (logic is obviously JS), such as Google's code prettifyer

    3. Two good lists of syntax highlighting engines are:

    4. Please be aware that NONE of those generic highlighters work "100% correctly", the way the syntax highlighters work in good IDEs, because they use regular expressions for approximate parsing instead of lexers for actual language grammar parsing. More details on the Wiki