/[pkgs]/devel/perl/02_fix_pod2html_dl
ViewVC logotype

Contents of /devel/perl/02_fix_pod2html_dl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Wed Mar 11 22:01:05 2009 UTC (8 months, 1 week ago) by spot
Branch: MAIN
CVS Tags: F-12-split, perl-5_10_0-63_fc11, perl-5_10_0-61_fc11, perl-5_10_0-80_fc12, perl-5_10_0-81_fc12, perl-5_10_0-84_fc13, perl-5_10_0-82_fc13, perl-5_10_0-77_fc12, perl-5_10_0-83_fc13, perl-5_10_0-71_fc12, perl-5_10_0-75_fc12, perl-5_10_0-73_fc12, perl-5_10_0-68_fc11, perl-5_10_0-67_fc11, perl-5_10_0-64_fc11, perl-5_10_0-72_fc12, F-11-split, perl-5_10_0-62_fc11, perl-5_10_0-69_fc12, perl-5_10_0-79_fc12, perl-5_10_0-78_fc12, perl-5_10_0-70_fc12, perl-5_10_0-74_fc12, perl-5_10_0-66_fc11, perl-5_10_0-65_fc11, perl-5_10_0-76_fc12, HEAD
reorder @INC, fix bz 489204, merge useful debian patches
1 Fix issue with (nested) definition lists in lib/Pod/Html.pm
2 - <dt> tags are not closed
3 - generated code contains spurious </li> closing tags
4 - when other (definition) lists are nested in a definition list, the
5 indentation of sublevels gets messed up because of incorrect
6 placement of <dt> tags
7
8 http://rt.perl.org/rt3/Public/Bug/Display.html?id=45211
9
10 Upstream change 32727.
11 diff -Naur --exclude=debian perl-5.10.0.orig/lib/Pod/Html.pm perl-5.10.0/lib/Pod/Html.pm
12 --- perl-5.10.0.orig/lib/Pod/Html.pm 2007-11-18 02:26:23.000000000 +1100
13 +++ perl-5.10.0/lib/Pod/Html.pm 2007-11-25 22:17:02.000000000 +1100
14 @@ -246,8 +246,8 @@
15 my $Doindex;
16
17 my $Backlink;
18 -my($Listlevel, @Listend);
19 -my $After_Lpar;
20 +my($Listlevel, @Listtype);
21 +my $ListNewTerm;
22 use vars qw($Ignore); # need to localize it later.
23
24 my(%Items_Named, @Items_Seen);
25 @@ -286,7 +286,7 @@
26 $Htmldir = ""; # The directory to which the html pages
27 # will (eventually) be written.
28 $Htmlfile = ""; # write to stdout by default
29 - $Htmlfileurl = "" ; # The url that other files would use to
30 + $Htmlfileurl = ""; # The url that other files would use to
31 # refer to this file. This is only used
32 # to make relative urls that point to
33 # other files.
34 @@ -302,8 +302,9 @@
35 $Doindex = 1; # non-zero if we should generate an index
36 $Backlink = ''; # text for "back to top" links
37 $Listlevel = 0; # current list depth
38 - @Listend = (); # the text to use to end the list.
39 - $After_Lpar = 0; # set to true after a par in an =item
40 + @Listtype = (); # list types for open lists
41 + $ListNewTerm = 0; # indicates new term in definition list; used
42 + # to correctly open/close <dd> tags
43 $Ignore = 1; # whether or not to format text. we don't
44 # format text until we hit our first pod
45 # directive.
46 @@ -519,7 +520,6 @@
47
48 # now convert this file
49 my $after_item; # set to true after an =item
50 - my $need_dd = 0;
51 warn "Converting input file $Podfile\n" if $Verbose;
52 foreach my $i (0..$#poddata){
53 $_ = $poddata[$i];
54 @@ -527,7 +527,6 @@
55 if (/^(=.*)/s) { # is it a pod directive?
56 $Ignore = 0;
57 $after_item = 0;
58 - $need_dd = 0;
59 $_ = $1;
60 if (/^=begin\s+(\S+)\s*(.*)/si) {# =begin
61 process_begin($1, $2);
62 @@ -543,12 +542,12 @@
63 if (/^=(head[1-6])\s+(.*\S)/s) { # =head[1-6] heading
64 process_head( $1, $2, $Doindex && $index );
65 } elsif (/^=item\s*(.*\S)?/sm) { # =item text
66 - $need_dd = process_item( $1 );
67 + process_item( $1 );
68 $after_item = 1;
69 } elsif (/^=over\s*(.*)/) { # =over N
70 process_over();
71 } elsif (/^=back/) { # =back
72 - process_back($need_dd);
73 + process_back();
74 } elsif (/^=for\s+(\S+)\s*(.*)/si) {# =for
75 process_for($1,$2);
76 } else {
77 @@ -563,8 +562,14 @@
78 next if $Ignore;
79 next if @Begin_Stack && $Begin_Stack[-1] ne 'html';
80 print HTML and next if @Begin_Stack && $Begin_Stack[-1] eq 'html';
81 - print HTML "<dd>\n" if $need_dd;
82 my $text = $_;
83 +
84 + # Open tag for definition list as we have something to put in it
85 + if( $ListNewTerm ){
86 + print HTML "<dd>\n";
87 + $ListNewTerm = 0;
88 + }
89 +
90 if( $text =~ /\A\s+/ ){
91 process_pre( \$text );
92 print HTML "<pre>\n$text</pre>\n";
93 @@ -594,12 +599,8 @@
94 }
95 ## end of experimental
96
97 - if( $after_item ){
98 - $After_Lpar = 1;
99 - }
100 print HTML "<p>$text</p>\n";
101 }
102 - print HTML "</dd>\n" if $need_dd;
103 $after_item = 0;
104 }
105 }
106 @@ -1074,12 +1075,12 @@
107
108 # figure out what kind of item it is.
109 # Build string for referencing this item.
110 - if ( $txt =~ /\A=item\s+\*\s*(.*)\Z/s ) { # bullet
111 + if ( $txt =~ /\A=item\s+\*\s*(.*)\Z/s ) { # bulleted list
112 next unless $1;
113 $item = $1;
114 } elsif( $txt =~ /\A=item\s+(?>\d+\.?)\s*(.*)\Z/s ) { # numbered list
115 $item = $1;
116 - } elsif( $txt =~ /\A=item\s+(.*)\Z/s ) { # plain item
117 + } elsif( $txt =~ /\A=item\s+(.*)\Z/s ) { # definition list
118 $item = $1;
119 } else {
120 next;
121 @@ -1099,12 +1100,7 @@
122 $tag =~ /head([1-6])/;
123 my $level = $1;
124
125 - if( $Listlevel ){
126 - warn "$0: $Podfile: unterminated list at =head in paragraph $Paragraph. ignoring.\n" unless $Quiet;
127 - while( $Listlevel ){
128 - process_back();
129 - }
130 - }
131 + finish_list();
132
133 print HTML "<p>\n";
134 if( $level == 1 && ! $Top ){
135 @@ -1143,19 +1139,32 @@
136 $name = anchorify($name);
137 print HTML qq{<a name="$name" class="item">}, process_text( \$otext ), '</a>';
138 }
139 - print HTML "</strong>\n";
140 + print HTML "</strong>";
141 undef( $EmittedItem );
142 }
143
144 -sub emit_li {
145 +sub new_listitem {
146 my( $tag ) = @_;
147 + # Open tag for definition list as we have something to put in it
148 + if( ($tag ne 'dl') && ($ListNewTerm) ){
149 + print HTML "<dd>\n";
150 + $ListNewTerm = 0;
151 + }
152 +
153 if( $Items_Seen[$Listlevel]++ == 0 ){
154 - push( @Listend, "</$tag>" );
155 + # start of new list
156 + push( @Listtype, "$tag" );
157 print HTML "<$tag>\n";
158 + } else {
159 + # if this is not the first item, close the previous one
160 + if ( $tag eq 'dl' ){
161 + print HTML "</dd>\n" unless $ListNewTerm;
162 + } else {
163 + print HTML "</li>\n";
164 + }
165 }
166 - my $emitted = $tag eq 'dl' ? 'dt' : 'li';
167 - print HTML "<$emitted>";
168 - return $emitted;
169 + my $opentag = $tag eq 'dl' ? 'dt' : 'li';
170 + print HTML "<$opentag>";
171 }
172
173 #
174 @@ -1163,7 +1172,6 @@
175 #
176 sub process_item {
177 my( $otext ) = @_;
178 - my $need_dd = 0; # set to 1 if we need a <dd></dd> after an item
179
180 # lots of documents start a list without doing an =over. this is
181 # bad! but, the proper thing to do seems to be to just assume
182 @@ -1173,43 +1181,41 @@
183 process_over();
184 }
185
186 - # formatting: insert a paragraph if preceding item has >1 paragraph
187 - if( $After_Lpar ){
188 - print HTML $need_dd ? "</dd>\n" : "</li>\n" if $After_Lpar;
189 - $After_Lpar = 0;
190 - }
191 -
192 # remove formatting instructions from the text
193 my $text = depod( $otext );
194
195 - my $emitted; # the tag actually emitted, used for closing
196 -
197 # all the list variants:
198 if( $text =~ /\A\*/ ){ # bullet
199 - $emitted = emit_li( 'ul' );
200 + new_listitem( 'ul' );
201 if ($text =~ /\A\*\s+(\S.*)\Z/s ) { # with additional text
202 my $tag = $1;
203 $otext =~ s/\A\*\s+//;
204 emit_item_tag( $otext, $tag, 1 );
205 + print HTML "\n";
206 }
207
208 } elsif( $text =~ /\A\d+/ ){ # numbered list
209 - $emitted = emit_li( 'ol' );
210 + new_listitem( 'ol' );
211 if ($text =~ /\A(?>\d+\.?)\s*(\S.*)\Z/s ) { # with additional text
212 my $tag = $1;
213 $otext =~ s/\A\d+\.?\s*//;
214 emit_item_tag( $otext, $tag, 1 );
215 + print HTML "\n";
216 }
217
218 } else { # definition list
219 - $emitted = emit_li( 'dl' );
220 + # new_listitem takes care of opening the <dt> tag
221 + new_listitem( 'dl' );
222 if ($text =~ /\A(.+)\Z/s ){ # should have text
223 emit_item_tag( $otext, $text, 1 );
224 + # write the definition term and close <dt> tag
225 + print HTML "</dt>\n";
226 }
227 - $need_dd = 1;
228 + # trigger opening a <dd> tag for the actual definition; will not
229 + # happen if next paragraph is also a definition term (=item)
230 + $ListNewTerm = 1;
231 }
232 print HTML "\n";
233 - return $need_dd;
234 }
235
236 #
237 @@ -1219,30 +1225,31 @@
238 # start a new list
239 $Listlevel++;
240 push( @Items_Seen, 0 );
241 - $After_Lpar = 0;
242 }
243
244 #
245 # process_back - process a pod back tag and convert it to HTML format.
246 #
247 sub process_back {
248 - my $need_dd = shift;
249 if( $Listlevel == 0 ){
250 warn "$0: $Podfile: unexpected =back directive in paragraph $Paragraph. ignoring.\n" unless $Quiet;
251 return;
252 }
253
254 - # close off the list. note, I check to see if $Listend[$Listlevel] is
255 + # close off the list. note, I check to see if $Listtype[$Listlevel] is
256 # defined because an =item directive may have never appeared and thus
257 - # $Listend[$Listlevel] may have never been initialized.
258 + # $Listtype[$Listlevel] may have never been initialized.
259 $Listlevel--;
260 - if( defined $Listend[$Listlevel] ){
261 - print HTML $need_dd ? "</dd>\n" : "</li>\n" if $After_Lpar;
262 - print HTML $Listend[$Listlevel];
263 - print HTML "\n";
264 - pop( @Listend );
265 + if( defined $Listtype[$Listlevel] ){
266 + if ( $Listtype[$Listlevel] eq 'dl' ){
267 + print HTML "</dd>\n" unless $ListNewTerm;
268 + } else {
269 + print HTML "</li>\n";
270 + }
271 + print HTML "</$Listtype[$Listlevel]>\n";
272 + pop( @Listtype );
273 + $ListNewTerm = 0;
274 }
275 - $After_Lpar = 0;
276
277 # clean up item count
278 pop( @Items_Seen );
279 @@ -2025,9 +2032,11 @@
280 # after the entire pod file has been read and converted.
281 #
282 sub finish_list {
283 - while ($Listlevel > 0) {
284 - print HTML "</dl>\n";
285 - $Listlevel--;
286 + if( $Listlevel ){
287 + warn "$0: $Podfile: unterminated list(s) at =head in paragraph $Paragraph. ignoring.\n" unless $Quiet;
288 + while( $Listlevel ){
289 + process_back();
290 + }
291 }
292 }
293
294 diff -Naur --exclude=debian perl-5.10.0.orig/lib/Pod/t/htmllink.t perl-5.10.0/lib/Pod/t/htmllink.t
295 --- perl-5.10.0.orig/lib/Pod/t/htmllink.t 2007-11-18 02:26:23.000000000 +1100
296 +++ perl-5.10.0/lib/Pod/t/htmllink.t 2007-11-25 22:17:02.000000000 +1100
297 @@ -108,24 +108,21 @@
298 <h2><a name="section_three">section three</a></h2>
299 <p>This is section three.</p>
300 <dl>
301 -<dt><strong><a name="item1" class="item">item1</a></strong>
302 +<dt><strong><a name="item1" class="item">item1</a></strong></dt>
303
304 <dd>
305 <p>This is item one.</p>
306 </dd>
307 -</li>
308 -<dt><strong><a name="item_2" class="item">item 2</a></strong>
309 +<dt><strong><a name="item_2" class="item">item 2</a></strong></dt>
310
311 <dd>
312 <p>This is item two.</p>
313 </dd>
314 -</li>
315 -<dt><strong><a name="item_three" class="item">item three</a></strong>
316 +<dt><strong><a name="item_three" class="item">item three</a></strong></dt>
317
318 <dd>
319 <p>This is item three.</p>
320 </dd>
321 -</li>
322 </dl>
323
324 </body>
325 diff -Naur --exclude=debian perl-5.10.0.orig/lib/Pod/t/htmlview.pod perl-5.10.0/lib/Pod/t/htmlview.pod
326 --- perl-5.10.0.orig/lib/Pod/t/htmlview.pod 2007-11-18 02:26:23.000000000 +1100
327 +++ perl-5.10.0/lib/Pod/t/htmlview.pod 2007-11-25 22:17:02.000000000 +1100
328 @@ -110,7 +110,7 @@
329
330 =head1 TESTING FOR AND BEGIN
331
332 -=for html <br>
333 +=for html <br />
334 <p>
335 blah blah
336 </p>
337 diff -Naur --exclude=debian perl-5.10.0.orig/lib/Pod/t/htmlview.t perl-5.10.0/lib/Pod/t/htmlview.t
338 --- perl-5.10.0.orig/lib/Pod/t/htmlview.t 2007-11-18 02:26:23.000000000 +1100
339 +++ perl-5.10.0/lib/Pod/t/htmlview.t 2007-11-25 22:17:02.000000000 +1100
340 @@ -86,17 +86,15 @@
341 <h2><a name="new__"><code>new()</code></a></h2>
342 <p>Constructor method. Accepts the following config options:</p>
343 <dl>
344 -<dt><strong><a name="foo" class="item">foo</a></strong>
345 +<dt><strong><a name="foo" class="item">foo</a></strong></dt>
346
347 <dd>
348 <p>The foo item.</p>
349 </dd>
350 -</li>
351 -<dt><strong><a name="bar" class="item">bar</a></strong>
352 +<dt><strong><a name="bar" class="item">bar</a></strong></dt>
353
354 <dd>
355 <p>The bar item.</p>
356 -</dd>
357 <p>This is a list within a list</p>
358 <ul>
359 <li>
360 @@ -106,30 +104,36 @@
361 <p>The waz item.</p>
362 </li>
363 </ul>
364 -<dt><strong><a name="baz" class="item">baz</a></strong>
365 +</dd>
366 +<dt><strong><a name="baz" class="item">baz</a></strong></dt>
367
368 <dd>
369 <p>The baz item.</p>
370 </dd>
371 -</li>
372 </dl>
373 <p>Title on the same line as the =item + * bullets</p>
374 <ul>
375 <li><strong><a name="black_cat" class="item"><code>Black</code> Cat</a></strong>
376
377 +</li>
378 <li><strong><a name="sat_on_the" class="item">Sat <em>on</em>&nbsp;the</a></strong>
379
380 +</li>
381 <li><strong><a name="mat" class="item">Mat&lt;!&gt;</a></strong>
382
383 +</li>
384 </ul>
385 <p>Title on the same line as the =item + numerical bullets</p>
386 <ol>
387 <li><strong><a name="cat" class="item">Cat</a></strong>
388
389 +</li>
390 <li><strong><a name="sat" class="item">Sat</a></strong>
391
392 +</li>
393 <li><strong><a name="mat2" class="item">Mat</a></strong>
394
395 +</li>
396 </ol>
397 <p>No bullets, no title</p>
398 <dl>
399 @@ -137,17 +141,14 @@
400 <dd>
401 <p>Cat</p>
402 </dd>
403 -</li>
404 <dt>
405 <dd>
406 <p>Sat</p>
407 </dd>
408 -</li>
409 <dt>
410 <dd>
411 <p>Mat</p>
412 </dd>
413 -</li>
414 </dl>
415 <p>
416 </p>
417 @@ -157,7 +158,7 @@
418 </p>
419 <hr />
420 <h1><a name="testing_for_and_begin">TESTING FOR AND BEGIN</a></h1>
421 -<br>
422 +<br />
423 <p>
424 blah blah
425 </p><p>intermediate text</p>

admin@fedoraproject.org
ViewVC Help
Powered by ViewVC 1.1.2