Skip to content

Commit

Permalink
Fix XHTML so that multiparagraph list items work correctly.
Browse files Browse the repository at this point in the history
Fix XHTML ordered list output so that it does not include the number specified
in the POD in the output. This is on a par with out the HTML output works.
  • Loading branch information
theory committed Dec 4, 2009
1 parent a0d6647 commit 2bab112
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 18 deletions.
11 changes: 9 additions & 2 deletions ChangeLog
Expand Up @@ -19,10 +19,17 @@
David E. Wheeler.

XHTML output now properly encodes entities in all places, not just
in verbatim blocks and code spans. David E. Wheler
in verbatim blocks and code spans. David E. Wheler.

Fixed XHTML to output definition lists when it should, rather than
(broken) unordered lists. David E. Wheeler
(broken) unordered lists. David E. Wheeler.

Fixed XHTML so that multiparagraph list items work correctly.
David E. Wheeler.

Fixed XHTML ordered list output so that it does not include the
number specified in the POD in the output. This is on a par with
out the HTML output works. David E. Wheeler.

2009-07-16 Allison Randal <allison@perl.org>
* Release 3.08
Expand Down
33 changes: 27 additions & 6 deletions lib/Pod/Simple/XHTML.pm
Expand Up @@ -236,8 +236,18 @@ sub start_head2 { $_[0]{'in_head'} = 2 }
sub start_head3 { $_[0]{'in_head'} = 3 }
sub start_head4 { $_[0]{'in_head'} = 4 }

sub start_item_bullet { $_[0]{'scratch'} = '<li>' }
sub start_item_number { $_[0]{'scratch'} = "<li>$_[1]{'number'}. " }
sub start_item_number {
$_[0]{'scratch'} = "</li>\n" if $_[0]{'in_li'};
$_[0]{'scratch'} .= '<li><p>';
$_[0]{'in_li'} = 1
}

sub start_item_bullet {
$_[0]{'scratch'} = "</li>\n" if $_[0]{'in_li'};
$_[0]{'scratch'} .= '<li><p>';
$_[0]{'in_li'} = 1
}

sub start_item_text {
$_[0]{'scratch'} = "</dd>\n" if delete $_[0]{'in_dd'};
$_[0]{'scratch'} .= '<dt>';
Expand All @@ -248,9 +258,20 @@ sub start_over_text { $_[0]{'scratch'} = '<dl>'; $_[0]->emit }
sub start_over_block { $_[0]{'scratch'} = '<ul>'; $_[0]->emit }
sub start_over_number { $_[0]{'scratch'} = '<ol>'; $_[0]->emit }

sub end_over_bullet { $_[0]{'scratch'} .= '</ul>'; $_[0]->emit }
sub end_over_block { $_[0]{'scratch'} .= '</ul>'; $_[0]->emit }
sub end_over_number { $_[0]{'scratch'} .= '</ol>'; $_[0]->emit }

sub end_over_number {
$_[0]{'scratch'} = "</li>\n" if delete $_[0]{'in_li'};
$_[0]{'scratch'} .= '</ol>';
$_[0]->emit;
}

sub end_over_bullet {
$_[0]{'scratch'} = "</li>\n" if delete $_[0]{'in_li'};
$_[0]{'scratch'} .= '</ul>';
$_[0]->emit;
}

sub end_over_text {
$_[0]{'scratch'} = "</dd>\n" if delete $_[0]{'in_dd'};
$_[0]{'scratch'} .= '</dl>';
Expand Down Expand Up @@ -279,8 +300,8 @@ sub end_head2 { shift->_end_head(@_); }
sub end_head3 { shift->_end_head(@_); }
sub end_head4 { shift->_end_head(@_); }

sub end_item_bullet { $_[0]{'scratch'} .= '</li>'; $_[0]->emit }
sub end_item_number { $_[0]{'scratch'} .= '</li>'; $_[0]->emit }
sub end_item_bullet { $_[0]{'scratch'} .= '</p>'; $_[0]->emit }
sub end_item_number { $_[0]{'scratch'} .= '</p>'; $_[0]->emit }
sub end_item_text { $_[0]{'scratch'} .= "</dt>\n<dd>"; $_[0]{'in_dd'} = 1; $_[0]->emit }

# This handles =begin and =for blocks of all kinds.
Expand Down
26 changes: 16 additions & 10 deletions t/xhtml01.t
Expand Up @@ -86,10 +86,12 @@ EOPOD
is($results, <<'EOHTML', "simple bulleted list");
<ul>
<li>P: Gee, Brain, what do you want to do tonight?</li>
<li><p>P: Gee, Brain, what do you want to do tonight?</p>
<li>B: The same thing we do every night, Pinky. Try to take over the world!</li>
</li>
<li><p>B: The same thing we do every night, Pinky. Try to take over the world!</p>
</li>
</ul>
EOHTML
Expand All @@ -114,10 +116,12 @@ EOPOD
is($results, <<'EOHTML', "numbered list");
<ol>
<li>1. P: Gee, Brain, what do you want to do tonight?</li>
<li><p>P: Gee, Brain, what do you want to do tonight?</p>
<li>2. B: The same thing we do every night, Pinky. Try to take over the world!</li>
</li>
<li><p>B: The same thing we do every night, Pinky. Try to take over the world!</p>
</li>
</ol>
EOHTML
Expand Down Expand Up @@ -177,16 +181,16 @@ EOPOD
is($results, <<'EOHTML', "list with bullet and text headings");
<ul>
<li>Pinky
<li><p>Pinky</p>
<p>Gee, Brain, what do you want to do tonight?</p>
</li>
<li>Brain
</li>
<li><p>Brain</p>
<p>The same thing we do every night, Pinky. Try to take over the world!</p>
</li>
</li>
</ul>
EOHTML
Expand All @@ -206,10 +210,12 @@ EOPOD
is($results, <<'EOHTML', "bulleted author list");
<ul>
<li>Brain &lt;brain@binkyandthebrain.com&gt;</li>
<li><p>Brain &lt;brain@binkyandthebrain.com&gt;</p>
<li>Pinky &lt;pinky@binkyandthebrain.com&gt;</li>
</li>
<li><p>Pinky &lt;pinky@binkyandthebrain.com&gt;</p>
</li>
</ul>
EOHTML
Expand Down

0 comments on commit 2bab112

Please sign in to comment.