Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save PatrickCronin/8af88459cd3de23c01bc20cfb91044d8 to your computer and use it in GitHub Desktop.
Save PatrickCronin/8af88459cd3de23c01bc20cfb91044d8 to your computer and use it in GitHub Desktop.
Mojo::DOM text nodes dodge ->text and ->all_text?
> perl -MMojo::DOM -E'$x=Mojo::DOM->new("<span>1</span> a <span>2</span>")->child_nodes->each(sub{ say $_->type . " node `$_` (" . $_->all_text . ") has length " . length($_->all_text) })';
tag node `<span>1</span>` (1) has length 1
text node ` a ` () has length 0
tag node `<span>2</span>` (2) has length 1
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment