Skip to content

Commit

Permalink
treat a few more broken tags as text
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 21, 2013
1 parent b3fcefa commit d476cd4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
5 changes: 2 additions & 3 deletions lib/Mojo/DOM/HTML.pm
Expand Up @@ -8,7 +8,7 @@ has 'xml';
has tree => sub { ['root'] };

my $ATTR_RE = qr/
([^=\s>]+) # Key
([^<>=\s]+) # Key
(?:
\s*=\s*
(?:
Expand Down Expand Up @@ -78,8 +78,7 @@ my %INLINE = map { $_ => 1 } (
sub parse {
my ($self, $html) = @_;

my $tree = ['root'];
my $current = $tree;
my $current = my $tree = ['root'];
while ($html =~ m/\G$TOKEN_RE/gcs) {
my ($text, $pi, $comment, $cdata, $doctype, $tag, $runaway)
= ($1, $2, $3, $4, $5, $6, $11);
Expand Down
7 changes: 4 additions & 3 deletions t/mojo/dom.t
Expand Up @@ -100,13 +100,14 @@ is "$dom", <<EOF, 'right result';
<![CDATA[ yada yada]]>
<?boom lalalala ?>
<a bit broken little>
<very <br broken></very>
&lt; very broken
<br />
more text
</a></foo>
EOF
my $simple = $dom->at('foo simple.working[class^="wor"]');
is $simple->parent->all_text, 'test easy works well yada yada more text',
'right text';
is $simple->parent->all_text,
'test easy works well yada yada < very broken more text', 'right text';
is $simple->type, 'simple', 'right type';
is $simple->attrs('class'), 'working', 'right class attribute';
is $simple->text, 'easy', 'right text';
Expand Down

0 comments on commit d476cd4

Please sign in to comment.