NAME
Pistachio::Language - provides snippet(), which turns source code text into stylish HTML
VERSION
version 0.06
SYNOPSIS
# Get std_parse from lib-JBD:
use JBD::JSON 'std_parse';
# Define a Pistachio::Language object by specifying
# the tokens, css and (optionally) tranformer_rules subs;
# This way, the existing Pistachio core can render JSON
# into Github-styled HTML pages, even though Pistachio knows
# nothing about how to parse JSON, and gets all of its CSS
# CSS style information from this definition.
my $lang = Pistachio::Language->new('JSON',
tokens => sub {
my $tokens = std_parse 'json_text', shift;
[map Pistachio::Token->new($_->type, $_->value), @$tokens];
},
css => sub {
my %type_to_style = (
JsonNum => 'color:#008080',
JsonNull => 'color:#000',
JsonBool => 'color:#000',
JsonString => 'color:#D14',
JsonColon => 'color:#333',
JsonComma => 'color:#333',
JsonSquareBracket => 'color:#333',
JsonCurlyBrace => 'color:#333',
)
$type_to_style{$_[0] || ''} || '';
},
);
AUTHOR
Joel Dalley <joeldalley@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Joel Dalley.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.