Syntax::Highlight::Perl::Improved

Syntax::Highlight::Perl::Improved allows highlighting of Perl syntactical structures.
Download

Syntax::Highlight::Perl::Improved Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • David C.Y. Liu
  • Publisher web site:
  • http://search.cpan.org/~davidcyl/Syntax-Highlight-Perl-Improved-1.01/lib/Syntax/Highlight/Perl/Improved.pm

Syntax::Highlight::Perl::Improved Tags


Syntax::Highlight::Perl::Improved Description

Syntax::Highlight::Perl::Improved allows highlighting of Perl syntactical structures. Syntax::Highlight::Perl::Improved allows highlighting of Perl syntactical structures.SYNOPSIS # simple procedural use Syntax::Highlight::Perl::Improved ':BASIC'; # or ':FULL' print format_string($my_string); # OO use Syntax::Highlight::Perl::Improved; my $formatter = new Syntax::Highlight::Perl::Improved; print $formatter->format_string($my_string);This module provides syntax highlighting for Perl code. The design bias is roughly line-oriented and streamed (ie, processing a file line-by-line in a single pass). Provisions may be made in the future for tasks related to "back-tracking" (ie, re-doing a single line in the middle of a stream) such as speeding up state copying.ConstructorsThe only constructor provided is new(). When called on an existing object, new() will create a new copy of that object. Otherwise, new() creates a new copy of the (internal) Default Object. Note that the use of the procedural syntax modifies the Default Object and that those changes will be reflected in any subsequent new() calls.FormattingFormatting is done using the format_string() method. Call format_string() with one or more strings to format, or it will default to using $_.Setting and Getting FormatsYou can set the text used for formatting a syntax element using set_format() (or set the start and end format individually using set_start_format() and set_end_format(), respectively).You can also retrieve the text used for formatting for an element via get_start_format() or get_end_format. Bulk retrieval of the names or values of defined formats is possible via get_format_names_list() (names), get_start_format_values_list() and get_end_format_values_list().See "FORMAT TYPES" later in this document for information on what format elements can be used.Checking and Setting the StateYou can check certain aspects of the state of the formatter via the methods: in_heredoc(), in_string(), in_pod(), was_pod(), in_data(), and line_count().You can reset all of the above states (and a few other internal ones) using reset().Stable and Unstable Formatting ModesYou can set or check the stability of formatting via unstable().In unstable (TRUE) mode, formatting is not considered to be persistent with nested formats. Or, put another way, when unstable, the formatter can only "remember" one format at a time and must reinstate formatting for each token. An example of unstable formatting is using ANSI color escape sequences in a terminal.In stable (FALSE) mode (the default), formatting is considered persistent within arbitrarily nested formats. Even in stable mode, however, formatting is never allowed to span multiple lines; it is always fully closed at the end of the line and reinstated at the beginning of a new line, if necessary. This is to ensure properly balanced tags when only formatting a partial code snippet. An example of stable formatting is HTML.SubstitutionsUsing define_substitution(), you can have the formatter substitute certain strings with others, after the original string has been parsed (but before formatting is applied). This is useful for escaping characters special to the output mode (eg, > and < in HTML) without them affecting the way the code is parsed.You can retrieve the current substitutions (as a hash-ref) via substitutions(). Requirements: · Perl


Syntax::Highlight::Perl::Improved Related Software