Skip to content

Instantly share code, notes, and snippets.

View PatrickCronin's full-sized avatar

Patrick Cronin PatrickCronin

View GitHub Profile
@PatrickCronin
PatrickCronin / gist:8af88459cd3de23c01bc20cfb91044d8
Created May 6, 2021 15:38
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
>