Skip to content

Commit

Permalink
make entities example a little more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 31, 2015
1 parent 3b83c2c commit a6cef6b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions examples/entities.pl
@@ -1,10 +1,14 @@
use Mojo::Base -strict;
use Mojo::ByteStream 'b';
use Mojo::UserAgent;
use Mojo::Util 'trim';

# Extract named character references from HTML spec
my $tx = Mojo::UserAgent->new->get('https://html.spec.whatwg.org');
b($_->at('td > code')->text . ' ' . $_->children('td')->[1]->text)->trim->say
for $tx->res->dom('#named-character-references-table tbody > tr')->each;
# Extract named character references from HTML Living Standard
my $tx = Mojo::UserAgent->new->get('https://html.spec.whatwg.org');
my $rows = $tx->res->dom('#named-character-references-table tbody > tr');
for my $row ($rows->each) {
my $entity = $row->at('td > code')->text;
my $codepoints = $row->children('td')->[1]->text;
say trim "$entity $codepoints";
}

1;

0 comments on commit a6cef6b

Please sign in to comment.