Skip to content

Instantly share code, notes, and snippets.

@diegok
Created June 23, 2017 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diegok/2d01cfcc73b98bfb56b880efce92c14e to your computer and use it in GitHub Desktop.
Save diegok/2d01cfcc73b98bfb56b880efce92c14e to your computer and use it in GitHub Desktop.
use Mojo::DOM
use v5.24;
# Example of Mojo::DOM (7.33) mungling   whitespaces
my $dom = Mojo::DOM->new('<div><h1>This is<span>&nbsp;Just Some&nbsp;Test</span></h1></div>');
say $dom->content; # <div><h1>This is<span>Just SomeTest</span></h1></div>
say $dom->at('h1')->all_text # This isJust SomeTest
@diegok
Copy link
Author

diegok commented Jun 23, 2017

Hm.... is it an expected behaviour?

my $txt = $dom->all_text;
$txt =~ s/\xA0/ /g;
say $txt; # "This is Just Some Test"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment