Permalink
Browse files

Fixed various formatting errors

  • Loading branch information...
jonallen committed May 16, 2010
1 parent 78b45dd commit 0a819d6711455a2d2d477dd76269ef28447588f6
@@ -161,8 +161,8 @@ sub view_over {
$strip = qr/^\s*\*\s*/;
} elsif ($first_title =~ /^\s*\d+\.?\s*/) {
# '=item 1.' or '=item 1 ' => <ol>
- $start = "<ol>\n";
- $end = "</ol>\n";
+ $start = "<dl>\n";
+ $end = "</dl>\n";
$strip = qr/^\s*\d+\.?\s*/;
} else {
$start = "<ul>\n";
@@ -186,15 +186,24 @@ sub view_item {
my $over = ref $self ? $self->{ OVER } : \@OVER;
my $title = $item->title();
my $strip = $over->[-1];
+ my $start_tag = '<li>';
+ my $end_tag = '</li>';
if (defined $title) {
$title = $title->present($self) if ref $title;
- $title =~ s/$strip// if $strip;
+ $title =~ s/($strip)// if $strip;
+ if (defined $1) {
+ my $dt = $1;
+ if ($dt =~ /^\d+\.?/) {
+ $start_tag = "<dt>$dt</dt><dd>";
+ $end_tag = "</dd>";
+ }
+ }
if (length $title) {
my $anchor = escape($item->title->present('Pod::POM::View::Text'));
$title = qq{<a name="$anchor"></a><b>$title</b>};
}
}
- return '<li>'."$title\n".$item->content->present($self)."</li>\n";
+ return $start_tag."$title\n".$item->content->present($self).$end_tag."\n";
}
@@ -232,10 +241,18 @@ sub view_seq_link {
return $link;
}
- $link =~ s!<code.*?>(.*?)</code>!$1!g;
- $link =~ s!<a.*?>(.*?)</a>!$1!g;
+ #$link =~ s!<code.*?>(.*?)</code>!$1!g;
+ #$link =~ s!<a.*?>(.*?)</a>!$1!g;
+
+ # Naively remove HTML tags from link text (tags screw up formatting...)
+ $link =~ s/<.*?>//sg;
my ($text,$inferred,$page,$section,$type) = parselink($link);
+
+ $inferred =~ s/"//sg if $inferred;
+ $section = decode_entities($section) if $section;
+ $section =~ s/^"(.*)"$/$1/ if $section;
+
#warn "$link at $document_name\n" if ($link =~ /perlvar\//);
#{
# no warnings 'uninitialized';
View
@@ -13,12 +13,13 @@
#
# COPYRIGHT
# Copyright (C) 2000-2009 Andy Wardley. All Rights Reserved.
+# Copyright (C) 2009 Andrew Ford. All Rights Reserved.
#
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: POM.pm 71 2009-03-27 16:24:19Z ford $
+# $Id: POM.pm 88 2010-04-02 13:37:41Z ford $
#
#========================================================================
@@ -34,7 +35,7 @@ use Pod::POM::View::Pod;
use vars qw( $VERSION $DEBUG $ERROR $ROOT $TEXTSEQ $DEFAULT_VIEW );
use base qw( Exporter );
-$VERSION = '0.25';
+$VERSION = '0.27';
$DEBUG = 0 unless defined $DEBUG;
$ROOT = 'Pod::POM::Node::Pod'; # root node class
$TEXTSEQ = 'Pod::POM::Node::Sequence'; # text sequence class
@@ -174,6 +175,18 @@ sub parse_text {
$$line = 1;
$inpod = 0;
+ my @encchunks = split /^(=encoding.*)/m, $text;
+ $text = shift @encchunks;
+ while (@encchunks) {
+ my($encline,$chunk) = splice @encchunks, 0, 2;
+ require Encode;
+ my($encoding) = $encline =~ /^=encoding\s+(\S+)/;
+ Encode::from_to($chunk, $encoding, "utf8");
+ Encode::_utf8_on($chunk);
+ # $text .= "xxx$encline";
+ $text .= $chunk;
+ }
+
# patch from JJ
# while ($text =~ /(?:(.*?)(\n{2,}))|(.+$)/sg) {
while ($text =~ /(?:(.*?)((?:\s*\n){2,}))|(.+$)/sg) {
@@ -186,13 +199,6 @@ sub parse_text {
elsif ($type eq 'cut') { $inpod = 0; next }
else { $inpod = 1 };
- if ($self->{in_begin}) {
- unless ($type eq 'end') {
- $para = "$1$para";
- $type = "text";
- }
- }
-
if ($type eq 'meta') {
$self->{ META }
? $stack[0]->metadata(split(/\s+/, $para, 2))
@@ -359,12 +365,12 @@ sub parse_sequence {
elsif (defined $3) {
$rparen = $3;
$rparen =~ s/^\s+//;
- if ($rparen eq $stack[-1]->[RPAREN]) {
+ while ($rparen && $rparen =~ s/^$stack[-1]->[RPAREN]//) {
$cmd = $TEXTSEQ->new(pop(@stack))
|| return $self->error($TEXTSEQ->error());
push(@{ $stack[-1]->[CONTENT] }, $cmd);
}
- else {
+ if ($rparen) {
$self->warning((scalar @stack > 1
? "expected '$stack[-1]->[RPAREN]' not '$rparen'"
: "spurious '$rparen'"), $name, $line);
View
@@ -7,15 +7,17 @@
#
# AUTHOR
# Andy Wardley <abw@kfs.org>
+# Andrew Ford <a.ford@ford-mason.co.uk>
#
# COPYRIGHT
# Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved.
+# Copyright (C) 2009 Andrew Ford. All Rights Reserved.
#
# This module is free software; you can redistribute it and/or
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Constants.pm 32 2009-03-17 21:08:25Z ford $
+# $Id: Constants.pm 78 2009-08-20 20:44:53Z ford $
#
#========================================================================
@@ -24,8 +26,9 @@ package Pod::POM::Constants;
require 5.004;
use strict;
+
use vars qw( $VERSION @SEQUENCE @STATUS @EXPORT_OK %EXPORT_TAGS );
-use base qw( Exporter );
+use parent qw( Exporter );
$VERSION = sprintf("%d.%02d", q$Revision: 1.1.1.1 $ =~ /(\d+)\.(\d+)/);
@SEQUENCE = qw( CMD LPAREN RPAREN FILE LINE CONTENT );
@@ -63,12 +66,16 @@ Constants used by Pod::POM.
=head1 AUTHOR
-Andy Wardley E<LT>abw@kfs.orgE<gt>
+Andy Wardley E<lt>abw@kfs.orgE<gt>
+
+Andrew Ford E<lt>a.ford@ford-mason.co.ukE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved.
+Copyright (C) 2009 Andrew Ford. All Rights Reserved.
+
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
View
11 lib/Pod/POM/Node.pm 100755 → 100644
@@ -15,7 +15,7 @@
# modify it under the same terms as Perl itself.
#
# REVISION
-# $Id: Node.pm 60 2009-03-20 12:41:35Z ford $
+# $Id: Node.pm 88 2010-04-02 13:37:41Z ford $
#
#========================================================================
@@ -79,7 +79,7 @@ sub new {
no strict qw( refs );
$attribs = \%{"$class\::ATTRIBS"} || [ ];
$accept = \@{"$class\::ACCEPT"} || [ ];
- unless (defined (%{"$class\::ACCEPT"})) {
+ unless (%{"$class\::ACCEPT"}) {
%{"$class\::ACCEPT"} = (
map { ( $_ => $NODES->{ $_ } ) } @$accept,
);
@@ -185,7 +185,12 @@ sub present {
my $type = $self->{ type };
my $method = "view_$type";
DEBUG("presenting method $method to $view\n");
- return $view->$method($self, @args);
+ my $txt = $view->$method($self, @args);
+ if ($view->can("encode")){
+ return $view->encode($txt);
+ } else {
+ return $txt;
+ }
}
View
@@ -0,0 +1,65 @@
+#============================================================= -*-Perl-*-
+#
+# Pod::POM::Node::Begin
+#
+# DESCRIPTION
+# Module implementing specific nodes in a Pod::POM, subclassed from
+# Pod::POM::Node.
+#
+# AUTHOR
+# Andy Wardley <abw@kfs.org>
+# Andrew Ford <a.ford@ford-mason.co.uk>
+#
+# COPYRIGHT
+# Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved.
+# Copyright (C) 2009 Andrew Ford. All Rights Reserved.
+#
+# This module is free software; you can redistribute it and/or
+# modify it under the same terms as Perl itself.
+#
+# REVISION
+# $Id: Begin.pm 76 2009-08-20 20:41:33Z ford $
+#
+#========================================================================
+
+package Pod::POM::Node::Begin;
+
+use strict;
+
+use parent qw( Pod::POM::Node );
+use vars qw( %ATTRIBS @ACCEPT $EXPECT $ERROR );
+
+%ATTRIBS = ( format => undef );
+@ACCEPT = qw( text verbatim code );
+$EXPECT = 'end';
+
+1;
+
+=head1 NAME
+
+Pod::POM::Node::Begin - POM '=begin' node class
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+This module implements a specialization of the node class to represent '=begin' elements.
+
+=head1 AUTHOR
+
+Andrew Ford E<lt>a.ford@ford-mason.co.ukE<gt>
+
+Andy Wardley E<lt>abw@kfs.orgE<gt>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved.
+
+Copyright (C) 2009 Andrew Ford. All Rights Reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+Consult L<Pod::POM::Node> for a discussion of nodes.
View
@@ -0,0 +1,69 @@
+#============================================================= -*-Perl-*-
+#
+# Pod::POM::Node::Code
+#
+# DESCRIPTION
+# Module implementing specific nodes in a Pod::POM, subclassed from
+# Pod::POM::Node.
+#
+# AUTHOR
+# Andy Wardley <abw@kfs.org>
+# Andrew Ford <a.ford@ford-mason.co.uk>
+#
+# COPYRIGHT
+# Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved.
+# Copyright (C) 2009 Andrew Ford. All Rights Reserved.
+#
+# This module is free software; you can redistribute it and/or
+# modify it under the same terms as Perl itself.
+#
+# REVISION
+# $Id: Code.pm 76 2009-08-20 20:41:33Z ford $
+#
+#========================================================================
+
+package Pod::POM::Node::Code;
+
+use strict;
+
+use parent qw( Pod::POM::Node );
+use vars qw( %ATTRIBS $ERROR );
+
+%ATTRIBS = ( text => '' );
+
+sub present {
+ my ($self, $view) = @_;
+ $view ||= $Pod::POM::DEFAULT_VIEW;
+ return $view->view_code($self->{ text });
+}
+
+1;
+
+=head1 NAME
+
+Pod::POM::Node::Code -
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+This module implements a specialization of the node class to represent code elements.
+
+=head1 AUTHOR
+
+Andrew Ford E<lt>a.ford@ford-mason.co.ukE<gt>
+
+Andy Wardley E<lt>abw@kfs.orgE<gt>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2000, 2001 Andy Wardley. All Rights Reserved.
+
+Copyright (C) 2009 Andrew Ford. All Rights Reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+Consult L<Pod::POM::Node> for a discussion of nodes.
Oops, something went wrong.

0 comments on commit 0a819d6

Please sign in to comment.