The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojo::DOM58::Entities - Escape or unescape HTML entities in strings

SYNOPSIS

  use Mojo::DOM58::Entities qw(html_escape html_unescape);
  
  my $str = 'foo & bar';
  $str = html_unescape $str; # "foo & bar"
  $str = html_escape $str; # "foo & bar"

DESCRIPTION

Mojo::DOM58::Entities contains functions for escaping and unescaping HTML entities for Mojo::DOM58, based on functions from Mojo::Util. All functions are exported on demand.

FUNCTIONS

html_attr_unescape

  my $str = html_attr_unescape $escaped;

Same as "html_unescape", but handles special rules from the HTML Living Standard for HTML attributes.

  # "foo=bar&ltest=baz"
  html_attr_unescape 'foo=bar&ltest=baz';

  # "foo=bar<est=baz"
  html_attr_unescape 'foo=bar&lt;est=baz';

html_escape

 my $escaped = html_escape $str;

Escape unsafe characters &, <, >, ", and ' in string.

 html_escape '<div>'; # "&lt;div&gt;"

html_unescape

 my $str = html_unescape $escaped;

Unescape all HTML entities in string, according to the HTML Living Standard.

 html_unescape '&lt;div&gt'; # "<div>"

BUGS

Report issues related to the format of this distribution or Perl 5.8 support to the public bugtracker. Any other issues should be reported directly to the upstream Mojolicious issue tracker.

AUTHOR

Dan Book <dbook@cpan.org>

Code and tests adapted from Mojo::Util, a set of utilities by the Mojolicious team.

COPYRIGHT AND LICENSE

Copyright (c) 2008-2016 Sebastian Riedel and others.

Copyright (c) 2016 Dan Book for adaptation to standalone format.

This is free software, licensed under:

  The Artistic License 2.0 (GPL Compatible)

SEE ALSO

HTML::Entities