Encode and decode HTML entities in Perl 6
Branch: master
Clone or download
Mouq Update for Rakudo 2014.5; fix #4
The issue is with .perl apparently not minding combining chars properly.
In any case, the characters have just been converted to \x000 sequences,
which fixes the issue.

Also, "unit" has been added before file-level package markers.
Latest commit 57931c7 May 26, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/HTML Update for Rakudo 2014.5; fix #4 May 26, 2015
t Update README and add some tests Jan 26, 2015
LICENSE Initial commit Mar 8, 2014
META.info Added missing namespace to 'provides' Apr 3, 2015
README.md Update README and add some tests Jan 26, 2015
generate_entities_module.p6 Update for Rakudo 2014.5; fix #4 May 26, 2015

README.md

HTML::Entity

Generated from the official list of valid HTML entities and can decode entity-laden text via &decode-entities (or &decode if use … :ALL is given)

Can also encode basic entities via &encode-entities/&encode.

Synopsis

use HTML::Entity;

say encode-entities "This <em>needs</em> to be escaped & encoded!";
    # This &lt;em&gt;needs&lt;/em&gt; to be escaped &amp; encoded!
say decode-entities "4.99 &approx; 5"; # 4.99 ≈ 5
say HTML::Entity<&nesim;>              # ≂̸

use HTML::Entity :ALL;

say decode "fj&aumlril"; # fjäril
say encode "A & B < C";  # A &amp; B &lt; C