NAME
Syntax::Highlight::Basic::Output::Pygments - Render highlighted code as HTML with Pygments CSS classes
SYNOPSIS
use Syntax::Highlight::Basic::Parser;
use Syntax::Highlight::Basic::Output::Pygments;
my $parser = Syntax::Highlight::Basic::Parser->new(language => 'perl');
my $tokens = $parser->parse('if ($x) { print "hello"; }');
my $output = Syntax::Highlight::Basic::Output::Pygments->new(wrap => 1);
my $html = $output->convert($tokens);
# $html contains:
# <div class="highlight"><pre><code>
# <span class="k">if</span> <span class="p">(</span>...
DESCRIPTION
Syntax::Highlight::Basic::Output::Pygments converts parser token output into HTML with Pygments-compatible CSS class names. Each non-whitespace token is wrapped in a <span class="..."> element using the standard Pygments CSS class names.
This enables syntax-highlighted code to be styled by any Pygments-compatible CSS theme.
CONSTRUCTOR
new(%options)
Creates a new Output::Pygments instance.
Options:
wrap-
If true, the output is wrapped in:
<div class="highlight"><pre><code>...CONTENT...</code></pre></div>Default:
0(no wrapping).
METHODS
convert($parse_result)
Converts parser token output to an HTML string.
Parameter $parse_result is the array reference returned by Syntax::Highlight::Basic::Parser::parse().
Returns an HTML string with <span> elements.
CSS CLASS MAPPING
The following Vim highlight groups are mapped to Pygments CSS classes:
String→sCharacter→scNumber→mBoolean→kcFloat→mfFunction→nfConditional,Repeat,Keyword,Exception,Structure,Typedef→kLabel→nlOperator→oInclude,Define,Macro,PreCondit→cpStorageClass→kdTag→ntSpecialChar→seDelimiter→pSpecialComment,Debug→csComment→cConstant,Identifier→nStatement→kPreProc→cpType→ktSpecial→pUnderlined→geError→errTodo→c1
VERSION
0.1.0
AUTHOR
Sandor Patocs
LICENSE
This module is licensed under the same terms as Perl itself.
SEE ALSO
Syntax::Highlight::Basic, Syntax::Highlight::Basic::Parser, Syntax::Highlight::Basic::Output::HTML, Syntax::Highlight::Basic::Output::Ansi
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 223:
Non-ASCII character seen before =encoding in '→'. Assuming UTF-8