r9996 - in /trunk/libhtml-treebuilder-xpath-perl: Changes META.yml debian/changelog lib/HTML/TreeBuilder/XPath.pm t/HTML-TreeBuilder-XPath.t
jeremiah-guest at users.alioth.debian.org
jeremiah-guest at users.alioth.debian.org
Thu Nov 29 14:26:15 UTC 2007
Author: jeremiah-guest
Date: Thu Nov 29 14:26:15 2007
New Revision: 9996
URL: http://svn.debian.org/wsvn/?sc=1&rev=9996
Log:
* added new upstream version
* checked the files in the debian dir (thanks gregoa!)
Modified:
trunk/libhtml-treebuilder-xpath-perl/Changes
trunk/libhtml-treebuilder-xpath-perl/META.yml
trunk/libhtml-treebuilder-xpath-perl/debian/changelog
trunk/libhtml-treebuilder-xpath-perl/lib/HTML/TreeBuilder/XPath.pm
trunk/libhtml-treebuilder-xpath-perl/t/HTML-TreeBuilder-XPath.t
Modified: trunk/libhtml-treebuilder-xpath-perl/Changes
URL: http://svn.debian.org/wsvn/trunk/libhtml-treebuilder-xpath-perl/Changes?rev=9996&op=diff
==============================================================================
--- trunk/libhtml-treebuilder-xpath-perl/Changes (original)
+++ trunk/libhtml-treebuilder-xpath-perl/Changes Thu Nov 29 14:26:15 2007
@@ -1,5 +1,16 @@
$Id: /html-treebuilder-xpath/Changes 40 2006-05-15T07:42:34.182385Z mrodrigu $
Revision history for Perl extension HTML::TreeBuilder::XPath.
+
+-
+0.09
+
+ - added support for the id function, see RT #30792
+ at https://rt.cpan.org/Ticket/Display.html?id=30792 bug reported, and
+ a fix proposed by tokuhirom
+
+ - fixed a bug where the as_XML method on text nodes returned non escaped
+ text, spotted by Tatsuhiko Miyagawa
+ at the moment the output is quite ugly, as ugly as HTML::Element as_XML.
0.08
Modified: trunk/libhtml-treebuilder-xpath-perl/META.yml
URL: http://svn.debian.org/wsvn/trunk/libhtml-treebuilder-xpath-perl/META.yml?rev=9996&op=diff
==============================================================================
--- trunk/libhtml-treebuilder-xpath-perl/META.yml (original)
+++ trunk/libhtml-treebuilder-xpath-perl/META.yml Thu Nov 29 14:26:15 2007
@@ -1,15 +1,12 @@
---- #YAML:1.0
-name: HTML-TreeBuilder-XPath
-version: 0.08
-abstract: add XPath support to HTML::TreeBuilder
-license: ~
-generated_by: ExtUtils::MakeMaker version 6.31
-distribution_type: module
-requires:
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: HTML-TreeBuilder-XPath
+version: 0.09
+version_from: lib/HTML/TreeBuilder/XPath.pm
+installdirs: site
+requires:
HTML::TreeBuilder: 0
XML::XPathEngine: 0.08
-meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.2.html
- version: 1.2
-author:
- - Michel Rodriguez <mrodrigu at localdomain>
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30_01
Modified: trunk/libhtml-treebuilder-xpath-perl/debian/changelog
URL: http://svn.debian.org/wsvn/trunk/libhtml-treebuilder-xpath-perl/debian/changelog?rev=9996&op=diff
==============================================================================
--- trunk/libhtml-treebuilder-xpath-perl/debian/changelog (original)
+++ trunk/libhtml-treebuilder-xpath-perl/debian/changelog Thu Nov 29 14:26:15 2007
@@ -1,3 +1,9 @@
+libhtml-treebuilder-xpath-perl (0.09-1) unstable; urgency=low
+
+ * New upstream release
+
+ -- Jeremiah C. Foster <jeremiah at jeremiahfoster.com> Thu, 29 Nov 2007 15:25:15 +0100
+
libhtml-treebuilder-xpath-perl (0.08-1) UNRELEASED; urgency=low
[ Jeremiah C. Foster ]
Modified: trunk/libhtml-treebuilder-xpath-perl/lib/HTML/TreeBuilder/XPath.pm
URL: http://svn.debian.org/wsvn/trunk/libhtml-treebuilder-xpath-perl/lib/HTML/TreeBuilder/XPath.pm?rev=9996&op=diff
==============================================================================
--- trunk/libhtml-treebuilder-xpath-perl/lib/HTML/TreeBuilder/XPath.pm (original)
+++ trunk/libhtml-treebuilder-xpath-perl/lib/HTML/TreeBuilder/XPath.pm Thu Nov 29 14:26:15 2007
@@ -1,11 +1,14 @@
package HTML::TreeBuilder::XPath;
+
use strict;
use warnings;
use vars qw($VERSION);
-$VERSION = '0.08';
+$VERSION = '0.09';
+
+my %ENT= ( '&' => '&', '<' => '<', '>' => '>', );
package HTML::TreeBuilder::XPath;
@@ -26,6 +29,10 @@
sub getFirstChild { return undef; }
sub getLastChild { return undef; }
+sub getElementById
+ { my ($self, $id) = @_;
+ return scalar $self->look_down( id => $id);
+ }
sub to_number { return XML::XPathEngine::Number->new( shift->getValue); }
@@ -37,7 +44,7 @@
# easy cases
return 0 if( $a == $b);
- return 1 if( $a->is_inside($b)); # a starts after b
+ return 1 if( $a->is_inside($b)); # a starts after b
return -1 if( $b->is_inside($a)); # a starts before b
# lineage does not include the element itself
@@ -48,8 +55,8 @@
unless( $a_pile[-1] == $b_pile[-1])
{ warn "2 nodes not in the same pile: ", ref( $a), " - ", ref( $b), "\n";
print "a: ", $a->string_value, "\nb: ", $b->string_value, "\n";
+ return undef;
}
- return undef unless( $a_pile[-1] == $b_pile[-1]);
# find the first non common ancestors (they are siblings)
my $a_anc= pop @a_pile;
@@ -63,7 +70,7 @@
if( defined( $a_anc->{_rank}) && defined( $b_anc->{_rank}))
{ return $a_anc->{_rank} <=> $b_anc->{_rank}; }
else
- { warn "no rank found";
+ {
# from there move left and right and figure out the order
my( $a_prev, $a_next, $b_prev, $b_next)= ($a_anc, $a_anc, $b_anc, $b_anc);
while()
@@ -206,7 +213,19 @@
sub getValue { return shift->{_content}; }
sub isTextNode { return 1; }
sub getAttributes { return wantarray ? () : []; }
-sub as_XML { return shift->getValue; }
+
+# extracted from _HTML::Element as_XML
+sub as_XML
+ { my( $node, $entities)= @_;
+ my $content= $node->{_content};
+ if( $node->{_parent} && $node->{_parent}->{_tag} eq 'script')
+ { $content=~ s{(&\w+;)}{HTML::Entities::decode($1)}eg; }
+ else
+ { HTML::Element::_xml_escape($content); }
+ return $content;
+ }
+
+
sub getPreviousSibling
@@ -243,6 +262,12 @@
sub is_inside
{ my( $text, $node)= @_;
return $text->{_parent}->is_inside( $node);
+ }
+
+sub xml_escape
+ { my( $text)= @_;
+ $text=~ s{([&<>])}{$ENT{$1}}g;
+ return $text;
}
1;
@@ -392,7 +417,7 @@
=head1 AUTHOR
-Michel Rodriguez, E<lt>imirod at cpan.orgE<gt>
+Michel Rodriguez, E<lt>mirod at cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
Modified: trunk/libhtml-treebuilder-xpath-perl/t/HTML-TreeBuilder-XPath.t
URL: http://svn.debian.org/wsvn/trunk/libhtml-treebuilder-xpath-perl/t/HTML-TreeBuilder-XPath.t?rev=9996&op=diff
==============================================================================
--- trunk/libhtml-treebuilder-xpath-perl/t/HTML-TreeBuilder-XPath.t (original)
+++ trunk/libhtml-treebuilder-xpath-perl/t/HTML-TreeBuilder-XPath.t Thu Nov 29 14:26:15 2007
@@ -3,7 +3,7 @@
#########################
-use Test::More tests => 17;
+use Test::More tests => 19;
BEGIN { use_ok('HTML::TreeBuilder::XPath') };
#########################
@@ -51,6 +51,8 @@
is( $p->findvalue( './a[1]|./a[2]'), 'linksmore links', 'query on siblings of an element (ordered)');
is( $p->findvalue( './a[2]|./a[1]'), 'linksmore links', 'query on siblings of an element (not ordered)');
+is( $html->findvalue('id("foo")'), 'spans', 'id function');
+is( $html->findvalue('id("foo")/@id'), 'foo', 'id function (attribute)');
}
__END__
More information about the Pkg-perl-cvs-commits
mailing list