|
HTML::SyntaxHighlighter - a module for converting raw HTML into html-escaped, highlighted code; suitable for inclusion within a web page. |
HTML::SyntaxHighlighter - a module for converting raw HTML into html-escaped, highlighted code; suitable for inclusion within a web page.
Standalone
my $p = HTML::SyntaxHighlighter->new(); $p->parse_file( "$file" ) or die "Cannot open '$file': $!"...
From within HTML::Mason
<& /lib/header.m, title => "Formatted source code for '$file'", stylesheet => [ 'html_highlight.css' ] &>
<%perl>
my $path = "/usr/data/www/hyperspeed.org/projects/html/examples";
my $p = HTML::SyntaxHighlighter->new(
out_func => sub{ $m->out( @_ ) },
header => 0,
);
$p->parse_file( "$path/$file" ) or die "Cannot open '$path/$file': $!"; </%perl>
<& /lib/footer.m &>
<%once> use HTML::SyntaxHighlighter; </%once>
<%args> $file </%args>
This module is designed to take raw HTML code, either from a variable or a file, html-escape it and highlight it (using stylesheets), rendering it suitable for inclusion in a web page. It is build on top of HTML::Parser.
It is intended primarily for people wanting to include 'example HTML code' in an dynamically generated web page (be it created with CGI, HTML::Mason, or whatever); if you find other uses, please let me know.
Options can either be set from the constructor:
my $p = HTML::SyntaxHighlighter->new(
default_type => 'xhtml'
force_type => 1,
);
Or by calling method with the same name:
$p->debug( 1 );
out_func
$p->out_func( sub { $r->print( @_ ) } );
$p->out_func( \*DATAFILE );
$p->out_func( \$data );
The default value is '\*STDOUT'.
collapse_inlineheaderdefault_typeforce_typedebugbr
Pretty much all of the other methods you will use are inherited from the HTML::Parser manpage.
Included are slightly adapted docs for the two most commonly used methods.
parse_file( $file )parse( $string )
The module only generates the HTML. You will also require a stylesheet, which must either be included in or linked from your html file. One is included with this module ('examples/html_highlight.css'), which gives roughly the same colours as xemacs' html-mode does by default.
If you decide to make your own stylesheet, you will need definitions for the following:
Alex Bowley <kilinrax@cpan.org>
|
HTML::SyntaxHighlighter - a module for converting raw HTML into html-escaped, highlighted code; suitable for inclusion within a web page. |