The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Syntax::Highlight::Engine::Simple - Simple, fast and flexible Syntax Highlight Engine

VERSION

This document describes Syntax::Highlight::Engine::Simple version 0.0.1

SYNOPSIS

        use Syntax::Highlight::Engine::Simple;
        
        # Constractor
        $highlight = Syntax::Highlight::Engine::Simple->new(%hash);
        
        # Parameter configuration
        $highlight->setParams(%hash);
        
        # Syntax definision and addition
        $highlight->setSyntax(%hash);
        $highlight->appendSyntax(%hash);
        
        # Perse
        $highlight->doFile(%hash);
        $highlight->doStr(%hash);
        
        # Utilities
        $highlight->array2regexp(%hash);
        $highlight->getClassNames(%hash);

DESCRIPTION

This is a Syntax highlight Engine.

Advantages are as follows.

Simple

Provides you a simple interface for syntax definition by depending on regular expression.

Fast

This works much Faster than Text::VimColor or Syntax::Highlight::Engine::Kate.

Pure Perl

Here is a working example of This module.

http://jamadam.com/dev/cpan/demo/Syntax/Highlight/Engine/Simple/

INTERFACE

new

type

File type. This argument causes specific sub class to be loaded.

syntax

With this argument, you can assign rules in constractor.

setParams

html_escape_code_ref

HTML escape code ref. Default subroutine escapes 3 charactors '&', '<' and '>'.

setSyntax

Set the rules for highlight. It calles for a argument syntax in array.

            $highlighter->setSyntax(
                syntax => [
                    {
                        class => 'quote',
                        regexp => q@'.*?(?<!¥¥¥¥)'@,
                        allowed_container => ['tag'],
                    },
                    {
                        class => 'wquote',
                        regexp => q@".*?(?<!¥¥¥¥)"@,
                        allowed_container => ['tag'],
                    },
                ]
            );

The array can contain rules in hash which is consists of 3 keys, class, regexp and allowed_container.

class

This appears to the output SPAN tag.

regexp

Regular expression to be highlighted.

allowed_container

An array of class name. This restricts the regexp to stand only in the classes. This param also works to ease the regulation some time. The highlighting rules doesn't stand in any container in default. allowed_container eliminate it to be a daughter of them.

appendSyntax

Append syntax by giving a hash.

            $highlighter->setSyntax(
                syntax => {
                    class => 'quote',
                    regexp => q@'.*?(?<!¥¥¥¥)'@,
                    allowed_container => ['tag'],
                }
            );

doStr

Highlighting strings.

        $highlighter->doStr(
            str => $str,
            tab_width => 4
        );
str

String.

tab_width

Tab width for tab-space conversion. -1 for disable it. -1 is the defult.

doFile

Highlighting files.

        $highlighter->doStr(
            str => $str,
            tab_width => 4,
            encode => 'utf8'
        );
file

File name.

tab_width

Tab width for tab-space conversion. -1 for disable it. -1 is the defult.

encode

Set the encode of file. utf8 is the default.

array2regexp

This is a utility method for converting string array to regular expression.

getClassNames

Returns the class names in array.

DIAGNOSTICS

doStr method got undefined value
File open failed

CONFIGURATION AND ENVIRONMENT

Syntax::Highlight::Engine::Simple requires no configuration files or environment variables. Specific language syntax can be defined with sub classes and loaded in constractor if you give it the type argument.

DEPENDENCIES

UNIVERSAL::require

INCOMPATIBILITIES

None reported.

BUGS AND LIMITATIONS

No bugs have been reported.

Please report any bugs or feature requests to bug-syntax-highlight-engine-Simple@rt.cpan.org, or through the web interface at http://rt.cpan.org.

SEE ALSO

Syntax::Highlight::Engine::Simple::HTML
Syntax::Highlight::Engine::Simple::Perl

AUTHOR

Sugama Keita <sugama@jamadam.com>

LICENCE AND COPYRIGHT

Copyright (c) 2008, Sugama Keita <sugama@jamadam.com>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 499:

Non-ASCII character seen before =encoding in 'q@'.*?(?<!¥¥¥¥)'@,'. Assuming UTF-8