1Syntax::Highlight::PerlU6s(e3r)Contributed Perl DocumentSaytnitoanx::Highlight::Perl6(3)
2
3
4

NAME

6       Syntax::Highlight::Perl6 - Perl 6 Syntax Highlighter
7

VERSION

9       version 0.88
10

SYNOPSIS

12           ### NOTE: This is needed and will be removed in future releases
13           use STD;
14           use Syntax::Highlight::Perl6;
15
16           # Creates the Perl6 syntax highlighter object
17           my $p = Syntax::Highlight::Perl6->new(
18               text => 'my $foo;'
19           );
20
21           # Prints html that can be embedded in your pages
22           print $p->snippet_html;
23
24           # Prints html with css (useful for full pages)
25           print $p->simple_html;
26
27           # Prints html that has a JavaScript node viewer
28           print $p->full_html;
29
30           # Prints ANSI escaped color sequences (useful for console and IRC output)
31           print $p->ansi_text;
32
33           # Prints an array of token records (useful for other libraries)
34           print $p->tokens;
35

DESCRIPTION

37       "Syntax::Highlight::Perl6" parses Perl 6 source code using STD cpan
38       package.  It matches parse tree nodes to colors then returns them in
39       different output formats.  It can be used to create web pages with
40       colorful source code samples in its simple and snippet html modes, or
41       it can be used as a learning tool in examining STD.pm6's output using
42       the JavaScript node viewer in its full html mode. Or you can use its
43       parse tree Perl 5 records to build your next great idea.
44
45       The available output formats are:
46
47       ·   HTML (snippet,simple and full)
48
49       ·   ANSI escaped color sequences
50
51       ·   Perl 5 array of parse trees
52

SUBROUTINES/METHODS

54       This is an object-oriented module. The following methods are available:
55
56   new(options)
57       Returns the syntax highlighting object. It needs a hash of options.
58       The following options are available:
59
60       ·   text
61
62           This is a required option.  This is where you should provide the
63           Perl 6 code.
64
65       ·   rule
66
67           parse rule name for STD.pm6 to parse against (default: TOP)
68
69       ·   inline_resources
70
71           Flag to enable/disable CSS/JavaScript HTML inlining. (default: 0
72           (Disabled))
73
74       ·   resource_url
75
76           HTML resource url that will be appended when resource inlining is
77           disabled.
78
79       ·   page_title
80
81           HTML page title for "simple_html" and "full_html" (default: q{})
82
83       ·   utf8_decode
84
85           Flag to enable/disable utf8 decoding. (default: 1 (Enabled))
86
87       ·   tmp_prefix
88
89           STD temporary files directory prefix. (default: q{})
90
91   snippet_html
92       Returns the Perl 6 highlighted HTML string that can be embedded.  No
93       CSS or JavaScript is inside.
94
95   simple_html
96       Returns the Perl 6 highlighted HTML string. The HTML code is the same
97       as "full_html" but lacks a JavaScript Parse Tree Viewer.
98
99   full_html
100       Returns the Perl 6 highlighted HTML string. The HTML consists of a
101       JavaScript Parse Tree Viewer along with CSS-styling.  It can inlined if
102       "inline_resources" option is 1.
103
104   ansi_text
105       Returns a Perl highlighted ANSI escape color string.
106
107   tokens
108       Returns an array of hashes containing parsed token records.  The hash
109       record is structured as:
110
111           +-----------+---------+-----------+------------+---------+
112           | Matched   | Matched | Matched   | Parse tree | Matched |
113           | Last      | string  | rule      | separated  | Line    |
114           | Position  | buffer  | name      | by spaces  | Number  |
115           |           |         |           |            |         |
116           | $last_pos | $buffer | $rule     | $tree      | $lineno |
117           +-----------+---------+-----------+------------+---------+
118
119       An example of the "tokens" method in action:
120
121           use Data::Dumper;
122           print Dumper($p->tokens);
123
124       The shortened output looks like:
125
126           $VAR1 = {
127             'tree' => '',
128             'rule' => 0,
129             'buffer' => '',
130             'last_pos' => 0
131           };
132           $VAR2 = {
133             'tree' => 'statementlist statement statement_modexpr statement_expr EXPR termish noun value number integer ',
134             'rule' => 'number',
135             'buffer' => '1',
136             'last_pos' => 1
137           };
138           $VAR3 = {
139             'tree' => 'statementlist eat_terminator ',
140             'rule' => 0,
141             'buffer' => ';',
142             'last_pos' => 2
143           };
144

INCOMPATIBILITIES

146       This module is dependent on Perl 5.10 features namely the regex engine
147       and state variables (for STD.pm6). So there will be no Perl 5.8.x
148       support in the future.
149

SEE ALSO

151       Discussion about this module and STD.pm6 is usually in #perl6
152       (irc://irc.freenode.net/perl6). This module lives in
153       http://svn.perlide.org/padre/trunk/Syntax-Highlight-Perl6 . Larry
154       Wall's "STD.pm6" lives in http://github.com/perl6/std.
155

BUGS AND LIMITATIONS

157       If you find any bugs, please submit them to
158       http://rt.cpan.org/NoAuth/Bugs.html?Dist=Syntax::Highlight::Perl6.
159       Thanks.
160
161       These are the bugs that i am currently aware of:
162
163       ·   Can't call method "bless" on an undefined value at STD.pm6 line
164           5269.
165
166           You have to put "use STD;" before using this module.
167
168               use STD; # this must be first for now
169               use Syntax::Highlight::Perl6;
170

ACKNOWLEDGEMENTS

172       The project idea was inspired by Moritz Lenz (moritz) -
173       http://www.nntp.perl.org/group/perl.perl6.users/2008/07/msg788.html .
174       Larry Wall's "gimme5"-generated Perl5 "STD.pmc" is included to parse
175       Perl 6 code.  The initial STD tree traversal code was written by Paweł
176       Murias (pmurias).  It was replaced afterwards for performance reasons
177       with Larry Wall's "redspans" traversal code. "redspans" stands for
178       "red" for reductions, and "spans" from the "from/to span calculations".
179
180       This library also includes the following libraries:
181
182       JQuery by John Resig (dual licensed under the MIT and GPL licenses).
183
184       Thanks guys. I could not have done it without you ;-)
185

AUTHOR

187       Ahmad M. Zawawi <ahmad.zawawi@gmail.com>
188
190       This software is copyright (c) 2010 by Ahmad M. Zawawi.
191
192       This is free software; you can redistribute it and/or modify it under
193       the same terms as the Perl 5 programming language system itself.
194

POD ERRORS

196       Hey! The above document had some coding errors, which are explained
197       below:
198
199       Around line 732:
200           Non-ASCII character seen before =encoding in 'Paweł'. Assuming
201           UTF-8
202
203
204
205perl v5.32.0                      2020-07-28       Syntax::Highlight::Perl6(3)
Impressum