Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 754 lines (527 sloc) 17.949 kb
b65a7d1 @rurban [GH #890] Add missing MANIFEST.generated files, cleanup
rurban authored
1 # Copyright (C) 2004-2012, Parrot Foundation.
7464e5f moving html formatting to filter
Michael Scott authored
2
3 =head1 NAME
4
4753978 Updated documentation for Parrot::*
Michael Scott authored
5 Parrot::Docs::POD2HTML - POD to HTML formatter
7464e5f moving html formatting to filter
Michael Scott authored
6
7 =head1 SYNOPSIS
8
908362b remove duplication of HTML docs header/footer
Michael Scott authored
9 use Parrot::Docs::POD2HTML;
7464e5f moving html formatting to filter
Michael Scott authored
10
11 =head1 DESCRIPTION
12
4753978 Updated documentation for Parrot::*
Michael Scott authored
13 C<Parrot::Docs::POD2HTML> subclasses C<Pod::Simple::HTML> to provide
14 various Parrot-specific formatting features, such as linking
15 C<CE<lt>Parrot::I<Module>E<gt>> and C<FE<lt>I<file>E<gt>>, and using the
16 Parrot house-style provided by C<Parrot::HTMLPage>.
7464e5f moving html formatting to filter
Michael Scott authored
17
4753978 Updated documentation for Parrot::*
Michael Scott authored
18 =head2 Instance Methods
7464e5f moving html formatting to filter
Michael Scott authored
19
20 =over
21
22 =cut
23
24 package Parrot::Docs::POD2HTML;
25
26 use strict;
62debfb @bschmalhofer Remove some explicit returns of 'undef'
bschmalhofer authored
27 use warnings;
7464e5f moving html formatting to filter
Michael Scott authored
28
a543b39 @bschmalhofer Consistently use 'use base' in .pm file below
bschmalhofer authored
29 use base qw( Pod::Simple::HTML );
62debfb @bschmalhofer Remove some explicit returns of 'undef'
bschmalhofer authored
30
7464e5f moving html formatting to filter
Michael Scott authored
31 # This is just here to keep Pod::Simple::HTML's version_tag_comment() happy.
62debfb @bschmalhofer Remove some explicit returns of 'undef'
bschmalhofer authored
32 our $VERSION = '1.0';
7464e5f moving html formatting to filter
Michael Scott authored
33
908362b remove duplication of HTML docs header/footer
Michael Scott authored
34 use Parrot::Docs::HTMLPage;
80fa0e2 @coke [docs] TT #477 - generate HTML for PASM/PIR targets in POD.
coke authored
35 use Parrot::Distribution;
2be29e8 @rurban [GH #890] Generate MANIFEST.generate, remove MANIFEST_configure.gener…
rurban authored
36 use Parrot::BuildUtil;
37 use Parrot::Config;
80fa0e2 @coke [docs] TT #477 - generate HTML for PASM/PIR targets in POD.
coke authored
38
39 =item C<new()>
40
41 Extend C<Pod::Simple::HTML> method to accept PIR and PASM sections that
42 contain example code, which will be put into a <pre> HTML element.
43
44 =cut
45
46 sub new {
47 my $new = shift->SUPER::new(@_);
48
72e50d8 @coke [docs] 'make html' now understands all the PIR/PASM targets
coke authored
49 $new->accept_targets(qw(
50 PIR PASM PIR_FRAGMENT
51 PIR_INVALID PIR_TODO
52 PASM_INVALID PASM_TODO
53 PIR_FRAGMENT_INVALID
54 ));
80fa0e2 @coke [docs] TT #477 - generate HTML for PASM/PIR targets in POD.
coke authored
55 delete(@{$new->{'Tagmap'}}{'Data','/Data'});
56
57 return $new;
58 }
908362b remove duplication of HTML docs header/footer
Michael Scott authored
59
5a5caff @paultcochrane [lib/Parrot] Removed trailing whitespace (part 11)
paultcochrane authored
60 =item C<do_beginning()>
7464e5f moving html formatting to filter
Michael Scott authored
61
c4d2fd6 moved formatting to formatter and simplified some sections
Michael Scott authored
62 Reimplements the C<Pod::Simple::HTML> method to add a header to the start
63 of the document.
7464e5f moving html formatting to filter
Michael Scott authored
64
65 =cut
66
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
67 sub do_beginning {
908362b remove duplication of HTML docs header/footer
Michael Scott authored
68 my $self = shift;
69
70 # We have to do this because it has the side effect of setting
71 # content_seen.
72 $self->get_short_title();
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
73
908362b remove duplication of HTML docs header/footer
Michael Scott authored
74 return unless $self->content_seen;
75
76 # Suppress the warning in the tests.
77 $self->{RESOURCES_URL} = '' unless $self->{RESOURCES_URL};
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
78 $self->{NAV_BAR} = '' unless $self->{NAV_BAR};
79
908362b remove duplication of HTML docs header/footer
Michael Scott authored
80 my $title = $self->{'Title'};
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
81 esc($title);
908362b remove duplication of HTML docs header/footer
Michael Scott authored
82
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
83 print { $self->{'output_fh'} }
84 Parrot::Docs::HTMLPage->header( $title, $self->{NAV_BAR}, $self->{RESOURCES_URL} );
908362b remove duplication of HTML docs header/footer
Michael Scott authored
85
86 $self->version_tag_comment;
87
88 return 1;
7464e5f moving html formatting to filter
Michael Scott authored
89 }
90
da70a71 Hyperlinks for F<path/file> and C<Perl::Module>, plus tidy up C<< >>…
Michael Scott authored
91 =item C<do_middle()>
92
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
93 Does the middle of the document. This splits up the long C<do_middle()>
94 method in C<Pod:Simple::HTML>, calling the various C<process_*> methods
95 below. This makes it easier to where the custom bits of Parrot-specific
96 formatting have to be inserted.
da70a71 Hyperlinks for F<path/file> and C<Perl::Module>, plus tidy up C<< >>…
Michael Scott authored
97
98 =cut
99
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
100 sub do_middle {
908362b remove duplication of HTML docs header/footer
Michael Scott authored
101 my $self = shift;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
102 my $token;
103 my $type;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
104
105 $self->{STACK} = [];
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
106 $self->{DONT_WRAP} = 0;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
107
108 while ( $token = $self->get_token ) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
109 $type = $token->type;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
110
111 if ( $type eq 'start' ) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
112 $self->process_start_token($token);
113 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
114 elsif ( $type eq 'end' ) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
115 $self->process_end_token($token);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
116 }
117 elsif ( $type eq 'text' ) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
118 $self->process_text_token($token);
908362b remove duplication of HTML docs header/footer
Michael Scott authored
119 }
120 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
121
908362b remove duplication of HTML docs header/footer
Michael Scott authored
122 return 1;
da70a71 Hyperlinks for F<path/file> and C<Perl::Module>, plus tidy up C<< >>…
Michael Scott authored
123 }
124
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
125 =item C<process_start_token($token)>
126
127 Process a start token.
128
129 =cut
130
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
131 sub process_start_token {
132 my $self = shift;
133 my $token = shift;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
134 my $tagname = $token->tagname;
135
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
136 if ( $tagname eq 'L' ) {
ee4cc2b @paultcochrane Undoing explicit return change in r19865
paultcochrane authored
137 $self->process_link_start_token($token);
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
138 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
139 elsif ( $tagname eq 'F' ) {
ee4cc2b @paultcochrane Undoing explicit return change in r19865
paultcochrane authored
140 $self->process_file_start_token($token);
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
141 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
142 elsif ( $tagname eq 'C' ) {
ee4cc2b @paultcochrane Undoing explicit return change in r19865
paultcochrane authored
143 $self->process_code_start_token($token);
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
144 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
145 elsif ( $tagname eq 'item-text' or $tagname =~ m/^head\d$/s ) {
ee4cc2b @paultcochrane Undoing explicit return change in r19865
paultcochrane authored
146 $self->process_item_text_or_head_start_token($token);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
147 }
148 elsif ( $tagname eq 'Data' ) {
ee4cc2b @paultcochrane Undoing explicit return change in r19865
paultcochrane authored
149 $self->process_data_start_token($token);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
150 }
80fa0e2 @coke [docs] TT #477 - generate HTML for PASM/PIR targets in POD.
coke authored
151 elsif ( $tagname eq 'for' ) {
152 $self->process_for_start_token($token);
153 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
154 else {
ee4cc2b @paultcochrane Undoing explicit return change in r19865
paultcochrane authored
155 $self->process_other_start_token($token);
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
156 }
157 }
158
159 =item C<process_link_start_token($token)>
160
161 Processes the link start token.
162
163 =cut
164
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
165 sub process_link_start_token {
166 my $self = shift;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
167 my $token = shift;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
168 my $text = $self->do_link($token);
169
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
170 esc($text);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
171
172 if ( defined $text and length $text ) {
173 print { $self->{'output_fh'} } "<a href='$text'>";
174 }
175 else {
176 print { $self->{'output_fh'} } "<a>";
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
177 }
178 }
179
180 =item C<process_code_start_token($token)>
181
182 Processes the code start token. If the code text is the name of a Parrot
183 Perl module, and the current documentation file is not the file for that
184 module, then the documentation file for the module is linked to.
185
186 =cut
187
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
188 sub process_code_start_token {
189 my $self = shift;
190 my $token = shift;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
191 my $tagname = $token->tagname;
192
193 # We make the code tags in items bold because they are almost
194 # always part of function and arguments, or constants listings
195 #Êand should stand out.
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
196
197 print { $self->{'output_fh'} } '<b>' if $self->{IN_ITEM_TEXT};
198
199 print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname};
200
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
201 my $next = $self->get_token;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
202
203 unless ( $next->type eq 'text' ) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
204 $self->unget_token($next);
205 return;
206 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
207
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
208 my $text = $next->text;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
209
b878029 @petdance removed unnecessary /o flags from regexes
petdance authored
210 if ( $text =~ /^Parrot::/ ) {
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
211
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
212 my $href = $self->href_for_perl_module($text);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
213
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
214 esc($text);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
215
216 if ($href) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
217 $text = "<a href='$href'>$text</a>";
218 }
219 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
220 else {
221
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
222 esc($text);
223 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
224
225 print { $self->{'output_fh'} } $text;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
226 }
227
228 =item C<process_file_start_token($token)>
229
230 Processes the file start token. If the text of the next token is a file
231 path and that file contains POD, then a link will be made to that file's
232 documentation file.
233
234 =cut
235
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
236 sub process_file_start_token {
237 my $self = shift;
238 my $token = shift;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
239 my $tagname = $token->tagname;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
240 my $next = $self->get_token;
241
242 if ( $next->type eq 'text' ) {
37e1047 fix module name hyperlinking; avoid hidden .files; add core.pm to docs
Michael Scott authored
243 my $text = $next->text;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
244 my $dist = Parrot::Distribution->new;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
245
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
246 # Only link to files that will have HTML pages.
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
247
248 if (
249 $dist->relative_path_is_file($text)
250
b4b718e Update configuration system documentation (based on patches provided …
Michael Scott authored
251 # A little bit of a hack to avoid config template files.
b878029 @petdance removed unnecessary /o flags from regexes
petdance authored
252 and $text !~ /\.in$/ and $dist->file_with_relative_path($text)->contains_pod
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
253 )
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
254 {
255 my $path = $self->append_html_suffix($text);
256 my $file = $self->{TARGET}->file_with_relative_path($path);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
257
258 print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname}
259 . $self->html_link( $self->{DOCS_FILE}->parent->relative_path($file), esc($text) );
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
260 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
261 else {
262 print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname} . esc($text);
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
263 }
264 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
265 else {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
266 $self->unget_token($next);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
267 print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname};
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
268 }
269 }
270
271 =item C<process_item_text_or_head_start_token($token)>
272
273 Process the item text or head start token.
274
275 =cut
276
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
277 sub process_item_text_or_head_start_token {
278 my $self = shift;
279 my $token = shift;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
280 my $tagname = $token->tagname;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
281
282 print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname} || return;
283
284 if ( $tagname eq 'item-text' ) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
285 $self->{IN_ITEM_TEXT} = 1;
286 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
287
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
288 my @to_unget;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
289
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
290 # Get all the contained tokens, including the end token.
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
291
292 while (1) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
293 push @to_unget, $self->get_token;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
294
295 last
296 if $to_unget[-1]->is_end
798af0f @paultcochrane [lib] Tidied code with perltidy
paultcochrane authored
297 and $to_unget[-1]->tagname eq $tagname;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
298 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
299
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
300 # Convert them into an anchor name;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
301
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
302 my $name = $self->linearize_tokens(@to_unget);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
303
304 if ( defined $name ) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
305 $name =~ tr/ /_/;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
306
307 print { $self->{'output_fh'} } qq(<a name="), esc($name), qq("\n>);
308
309 }
310 else {
311 print { $self->{'output_fh'} } "<a\n>";
312 }
313
ee4cc2b @paultcochrane Undoing explicit return change in r19865
paultcochrane authored
314 $self->unget_token(@to_unget);
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
315 }
316
317 =item C<process_data_start_token($token)>
318
319 Processes a data start token.
320
321 =cut
322
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
323 sub process_data_start_token {
324 my $self = shift;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
325 my $token = shift;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
326 my $next = $self->get_token;
327
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
328 return unless defined $next;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
329
330 unless ( $next->type eq 'text' ) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
331 $self->unget_token($next);
332 return;
333 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
334
80fa0e2 @coke [docs] TT #477 - generate HTML for PASM/PIR targets in POD.
coke authored
335 if ($self->{IN_CODE_BLOCK}) {
336 print { $self->{'output_fh'} } $next->text;
337 }
338 else {
339 print { $self->{'output_fh'} } "\n" . $next->text . "\n";
340 }
341 }
342
343 =item C<process_for_start_token($token)>
344
345 Processes a for start token.
346
347 =cut
348
349 sub process_for_start_token {
350 my $self = shift;
351 my $token = shift;
352 my $target = $token->attr("target");
353
72e50d8 @coke [docs] 'make html' now understands all the PIR/PASM targets
coke authored
354 if ($target =~ m/^(PIR|PASM)/) {
80fa0e2 @coke [docs] TT #477 - generate HTML for PASM/PIR targets in POD.
coke authored
355 print { $self->{'output_fh'} } '<pre>';
356 $self->{IN_CODE_BLOCK} = 1;
357 }
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
358 }
359
360 =item C<process_other_start_token($token)>
361
362 Processes a start token not processable by the above methods.
363
364 =cut
365
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
366 sub process_other_start_token {
367 my $self = shift;
368 my $token = shift;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
369 my $tagname = $token->tagname;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
370
371 if ( $tagname =~ m/^over-(.+)$/s ) {
372 push @{ $self->{STACK} }, $1;
373 }
374 elsif ( $tagname eq 'Para' ) {
375 $tagname = 'Para_item'
376 if @{ $self->{STACK} } and $self->{STACK}->[-1] eq 'text';
377 }
378
379 print { $self->{'output_fh'} } $self->{'Tagmap'}{$tagname} || return;
380
ee4cc2b @paultcochrane Undoing explicit return change in r19865
paultcochrane authored
381 ++$self->{DONT_WRAP}
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
382 if $tagname eq 'Verbatim'
798af0f @paultcochrane [lib] Tidied code with perltidy
paultcochrane authored
383 or $tagname eq "VerbatimFormatted"
384 or $tagname eq 'X';
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
385 }
386
387 =item C<process_end_token($token)>
388
389 Processes an end token.
390
391 =cut
392
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
393 sub process_end_token {
394 my $self = shift;
395 my $token = shift;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
396 my $tagname = $token->tagname;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
397
398 if ( $tagname =~ m/^over-/s ) {
399 pop @{ $self->{STACK} };
400 }
401 elsif ( $tagname eq 'Para' ) {
402 $tagname = 'Para_item'
403 if @{ $self->{STACK} } and $self->{STACK}->[-1] eq 'text';
404 }
405 elsif ( $tagname eq 'C' ) {
406
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
407 # See the note in process_code_start_token() above.
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
408 print { $self->{'output_fh'} } '</b>' if $self->{IN_ITEM_TEXT};
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
409 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
410 elsif ( $tagname eq 'item-text' ) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
411 $self->{IN_ITEM_TEXT} = 0;
412 }
80fa0e2 @coke [docs] TT #477 - generate HTML for PASM/PIR targets in POD.
coke authored
413 elsif ( $tagname eq 'for' ) {
414 print { $self->{'output_fh'} } '</pre>' if $self->{IN_CODE_BLOCK};
415 $self->{IN_CODE_BLOCK} = 0;
416 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
417
418 print { $self->{'output_fh'} } $self->{'Tagmap'}{"/$tagname"} || return;
419
ee4cc2b @paultcochrane Undoing explicit return change in r19865
paultcochrane authored
420 --$self->{DONT_WRAP} if $tagname eq 'Verbatim' or $tagname eq 'X';
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
421 }
422
423 =item C<process_text_token($token)>
424
425 Processes the specified text token. URLs which are not in link tags
426 are linked here for convenience.
427
428 =cut
429
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
430 sub process_text_token {
431 my $self = shift;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
432 my $token = shift;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
433 my $text = $token->text;
434
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
435 esc($text);
436 $text =~ s/([\?\!\"\'\.\,]) /$1\n/g unless $self->{DONT_WRAP};
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
437
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
438 # URLs not in L<>.
439 $text =~ s|(http://[^\s)]+)|<a href="$1">$1</a>|gs;
440
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
441 print { $self->{'output_fh'} } $text;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
442 }
443
444 =item C<do_pod_link($link)>
773180b Avoid a Pod::Simple::HTML bug in file.html#section links
Michael Scott authored
445
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
446 This is reimplemented here to avoid a bug in C<Pod::Simple::HTML>.
773180b Avoid a Pod::Simple::HTML bug in file.html#section links
Michael Scott authored
447
448 =cut
449
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
450 sub do_pod_link {
451 my $self = shift;
452 my $link = shift;
453 my $to = $link->attr('to');
908362b remove duplication of HTML docs header/footer
Michael Scott authored
454 my $section = $link->attr('section');
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
455
456 return
457 unless ( defined $to and length $to )
458 or ( defined $section and length $section );
459
460 if ( defined $to and length $to ) {
461 $to = $self->resolve_pod_page_link( $to, $section );
462
62debfb @bschmalhofer Remove some explicit returns of 'undef'
bschmalhofer authored
463 return unless defined $to and length $to;
908362b remove duplication of HTML docs header/footer
Michael Scott authored
464 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
465
466 if ( defined $section and length( $section .= '' ) ) {
908362b remove duplication of HTML docs header/footer
Michael Scott authored
467 $section =~ tr/ /_/;
468 $section =~ tr/\x00-\x1F\x80-\x9F//d if 'A' eq chr(65);
469 $section = $self->unicode_escape_url($section);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
470
908362b remove duplication of HTML docs header/footer
Michael Scott authored
471 # Turn char 1234 into "(1234)"
472 $section = '_' unless length $section;
473 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
474
475 foreach my $it ( $to, $section ) {
908362b remove duplication of HTML docs header/footer
Michael Scott authored
476 next unless defined $it;
477
478 $it =~ s/([^\x00-\xFF])/join '', map sprintf('%%%02X',$_), unpack 'C*', $1/eg;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
479 $it =~
480 s/([^\._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/sprintf('%%%02X',ord($1))/eg;
481
908362b remove duplication of HTML docs header/footer
Michael Scott authored
482 # Yes, stipulate the list without a range, so that this can work right on
483 # all charsets that this module happens to run under.
484 # Altho, hmm, what about that ord? Presumably that won't work right
485 # under non-ASCII charsets. Something should be done about that.
486 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
487
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
488 # Pod::Simple::HTML bug was here.
908362b remove duplication of HTML docs header/footer
Michael Scott authored
489 my $out;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
490
908362b remove duplication of HTML docs header/footer
Michael Scott authored
491 $out = $to if defined $to and length $to;
492 $out .= "#" . $section if defined $section and length $section;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
493
62debfb @bschmalhofer Remove some explicit returns of 'undef'
bschmalhofer authored
494 return unless length $out;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
495
496 return $out;
773180b Avoid a Pod::Simple::HTML bug in file.html#section links
Michael Scott authored
497 }
498
da70a71 Hyperlinks for F<path/file> and C<Perl::Module>, plus tidy up C<< >>…
Michael Scott authored
499 =item C<resolve_pod_page_link($to, $section)>
500
501 Resolves the POD link. Perl modules are converted to paths.
502
503 =cut
504
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
505 sub resolve_pod_page_link {
506 my $self = shift;
507 my $to = shift;
908362b remove duplication of HTML docs header/footer
Michael Scott authored
508 my $section = shift;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
509
b878029 @petdance removed unnecessary /o flags from regexes
petdance authored
510 if ( $to =~ /^Parrot::/ ) {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
511 my $href = $self->href_for_perl_module($to);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
512
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
513 # This gets corrupted somewhere down the line, with
514 # Parrot/PackFile/ConstTable.pm.html being turned into
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
515 # Parrot/PackFile%2FConstTable.pm.html and thus breaking
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
516 # the CSS and images somehow.
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
517
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
518 return $href if defined $href;
908362b remove duplication of HTML docs header/footer
Michael Scott authored
519 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
520
908362b remove duplication of HTML docs header/footer
Michael Scott authored
521 return 'TODO';
da70a71 Hyperlinks for F<path/file> and C<Perl::Module>, plus tidy up C<< >>…
Michael Scott authored
522 }
523
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
524 =item C<href_for_perl_module($module)>
525
526 Returns the path to the Perl module's HTML file relative to the current
527 documentation page. Currently only F<lib/Parrot> modules are linkable.
5a5caff @paultcochrane [lib/Parrot] Removed trailing whitespace (part 11)
paultcochrane authored
528 Returns C<undef> if the current documentation file is the file for the
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
529 module.
530
531 =cut
532
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
533 sub href_for_perl_module {
534 my $self = shift;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
535 my $module = shift;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
536
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
537 # This is not very obvious, so let me explain. We get the file
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
538 # for the module, then we take its path relative to the
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
539 # distribution, then we append the HTML suffix and get the
540 # docs file. Once we have that all we need is the relative
541 # path from the current directory to the file and return that
542 # as the link.
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
543
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
544 my $dist = Parrot::Distribution->new;
545 my $file = $dist->file_for_perl_module($module);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
546
62debfb @bschmalhofer Remove some explicit returns of 'undef'
bschmalhofer authored
547 return if not $file or not $file->contains_pod;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
548
549 my $path = $self->append_html_suffix( $dist->relative_path($file) );
550
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
551 # This is the docs file for the module.
552 $file = $self->{TARGET}->file_with_relative_path($path);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
553
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
554 # There's no point in linking to the file you are already in.
62debfb @bschmalhofer Remove some explicit returns of 'undef'
bschmalhofer authored
555 return if $file == $self->{DOCS_FILE};
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
556
557 return $self->href_path( $self->{DOCS_FILE}->parent->relative_path($file) );
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
558 }
559
7464e5f moving html formatting to filter
Michael Scott authored
560 =item C<do_end()>
561
c4d2fd6 moved formatting to formatter and simplified some sections
Michael Scott authored
562 Reimplements the C<Pod::Simple::HTML> method to add a footer to the end
563 of the document.
7464e5f moving html formatting to filter
Michael Scott authored
564
565 =cut
566
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
567 sub do_end {
908362b remove duplication of HTML docs header/footer
Michael Scott authored
568 my $self = shift;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
569
570 print { $self->{'output_fh'} } Parrot::Docs::HTMLPage->footer( '', $self->{RESOURCES_URL} );
571
908362b remove duplication of HTML docs header/footer
Michael Scott authored
572 return 1;
7464e5f moving html formatting to filter
Michael Scott authored
573 }
574
c4d2fd6 moved formatting to formatter and simplified some sections
Michael Scott authored
575 =item C<html_for_file($file)>
576
577 Returns the HTML for the specified file.
578
579 =cut
580
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
581 sub html_for_file {
582 my $self = shift;
583 my $file = shift;
908362b remove duplication of HTML docs header/footer
Michael Scott authored
584 my $string = "";
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
585
586 $self->output_string( \$string );
587 $self->parse_file( $file->path );
588
908362b remove duplication of HTML docs header/footer
Michael Scott authored
589 return $string;
c4d2fd6 moved formatting to formatter and simplified some sections
Michael Scott authored
590 }
591
8d5a4ad refactor and add navigatation
Michael Scott authored
592 =item C<write_html($source, $target, $rel_path, $item)>
593
594 Writes an HTML version of the file specified by C<$rel_path> in
595 C<$source> to the equivalent location in C<$target>.
596
597 =cut
598
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
599 sub write_html {
600 my $self = shift;
601 my $source = shift;
602 my $target = shift;
908362b remove duplication of HTML docs header/footer
Michael Scott authored
603 my $rel_path = shift;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
604 my $item = shift;
605 my $file = $source->file_with_relative_path($rel_path);
606
908362b remove duplication of HTML docs header/footer
Michael Scott authored
607 return unless $file->contains_pod;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
608
908362b remove duplication of HTML docs header/footer
Michael Scott authored
609 $self->{TARGET} = $target;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
610
908362b remove duplication of HTML docs header/footer
Michael Scott authored
611 # Use our own method for consistency.
433b25b use new parrotcode.org look
Michael Scott authored
612 $self->{'Title'} = $file->title;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
613
908362b remove duplication of HTML docs header/footer
Michael Scott authored
614 $rel_path = $self->append_html_suffix($rel_path);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
615
908362b remove duplication of HTML docs header/footer
Michael Scott authored
616 my $docs_file = $target->file_with_relative_path($rel_path);
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
617
908362b remove duplication of HTML docs header/footer
Michael Scott authored
618 $self->{DOCS_FILE} = $docs_file;
619
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
620 $rel_path = $self->href_path( $docs_file->parent->relative_path( $target->parent_path ) );
908362b remove duplication of HTML docs header/footer
Michael Scott authored
621
622 my $name = $target->name;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
623
908362b remove duplication of HTML docs header/footer
Michael Scott authored
624 # This is a cheat because we know that all top-level sections
625 # have their indexes in the root directory - but it works.
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
626
627 $self->{NAV_BAR} = $item->html_navigation("$rel_path/$name");
908362b remove duplication of HTML docs header/footer
Michael Scott authored
628 $self->{RESOURCES_URL} = "$rel_path/resources";
629
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
630 $docs_file->write( $self->html_for_file($file) );
2be29e8 @rurban [GH #890] Generate MANIFEST.generate, remove MANIFEST_configure.gener…
rurban authored
631
632 unless ($self->{TESTING}) {
b65a7d1 @rurban [GH #890] Add missing MANIFEST.generated files, cleanup
rurban authored
633 my $path = File::Spec->abs2rel(
634 File::Spec->catfile($docs_file->{PATH}), $PConfig{build_dir});
2be29e8 @rurban [GH #890] Generate MANIFEST.generate, remove MANIFEST_configure.gener…
rurban authored
635 chdir "..";
636 add_to_generated($path, "[main]", "html");
637 chdir "docs";
638 }
8d5a4ad refactor and add navigatation
Michael Scott authored
639 }
640
641 =item C<append_html_suffix($path)>
642
643 Returns C<$path> with and HTML file suffix added.
644
645 =cut
646
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
647 sub append_html_suffix {
908362b remove duplication of HTML docs header/footer
Michael Scott authored
648 my $self = shift;
649 my $path = shift;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
650
908362b remove duplication of HTML docs header/footer
Michael Scott authored
651 return $path . '.html';
8d5a4ad refactor and add navigatation
Michael Scott authored
652 }
653
682cbd7 possible fix for [perl #29302]
Michael Scott authored
654 =item C<html_link($href, $text)>
655
656 Returns an HTML anchor with the specified "href".
657
658 =cut
659
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
660 sub html_link {
682cbd7 possible fix for [perl #29302]
Michael Scott authored
661 my $self = shift;
662 my $href = $self->href_path(shift);
663 my $text = shift || $href;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
664
682cbd7 possible fix for [perl #29302]
Michael Scott authored
665 return "<a href=\"$href\">$text</a>";
666 }
667
668 =item href_path($path)
669
670 Converts the path for use in an "href".
671
672 Sequences of backslashes are converted to forward slash.
673
674 =cut
675
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
676 sub href_path {
682cbd7 possible fix for [perl #29302]
Michael Scott authored
677 my $self = shift;
678 my $path = shift;
679
680 $path =~ s|\\+|/|go;
681
682 return $path;
683 }
684
4753978 Updated documentation for Parrot::*
Michael Scott authored
685 =back
686
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
687 =head2 Functions
688
689 =over 4
690
691 =item C<esc(@strings)>
692
693 =item C<esc($string)>
694
695 Reimplemented here to silence a C<Pod::Simple::HTML> warning.
696
697 =cut
698
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
699 sub esc {
700 if ( defined wantarray ) {
701 if (wantarray) {
702 @_ = splice @_; # break aliasing
703 }
704 else {
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
705 my $x = shift;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
706
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
707 # Pod::Simple::HTML didn't check this.
708 return $x unless $x;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
709 $x =~
710 s/([^\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/'&#'.(ord($1)).';'/eg;
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
711 return $x;
712 }
713 }
714
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
715 foreach my $x (@_) {
716
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
717 # Pod::Simple::HTML didn't check this.
718 next unless $x;
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
719
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
720 # Escape things very cautiously:
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
721 $x =~
722 s/([^\n\t !\#\$\%\(\)\*\+,\.\~\/\:\;=\?\@\[\\\]\^_\`\{\|\}abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789])/'&#'.(ord($1)).';'/eg;
723
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
724 # Leave out "- so that "--" won't make it thru in X-generated comments
725 # with text in them.
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
726
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
727 # Yes, stipulate the list without a range, so that this can work right on
728 # all charsets that this module happens to run under.
729 # Altho, hmm, what about that ord? Presumably that won't work right
730 # under non-ASCII charsets. Something should be done about that.
731 }
7942baa @paultcochrane [lib/Parrot] Tidied Perl source with perltidy. (part 28)
paultcochrane authored
732
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
733 return @_;
734 }
735
7464e5f moving html formatting to filter
Michael Scott authored
736 =back
737
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
738 =head1 HISTORY
739
7a64048 @chromatic [lib] Tided some Perl 5 code; no functional changes.
chromatic authored
740 In order to avoid modifying C<Pod:Simple::HTML>, large sections of its code
741 have been copied here, and then refactored and adjusted to enable various bits
742 of Parrot-specific behaviour.
07b9ece A bit of refactoring of the POD parser to integrate Parrot-specific f…
Michael Scott authored
743
7464e5f moving html formatting to filter
Michael Scott authored
744 =cut
745
62debfb @bschmalhofer Remove some explicit returns of 'undef'
bschmalhofer authored
746 1;
7516efb @paultcochrane [lib] Added/corrected Parrot coda (part 3)
paultcochrane authored
747
748 # Local Variables:
749 # mode: cperl
750 # cperl-indent-level: 4
751 # fill-column: 100
752 # End:
753 # vim: expandtab shiftwidth=4:
Something went wrong with that request. Please try again.