HTML entity encoder/decoder for Gleam
Find a file
2023-05-28 17:19:30 +03:00
src Add HTMLBody encoding mode that doesn't encode quite so many characters 2023-05-28 17:19:30 +03:00
test Add HTMLBody encoding mode that doesn't encode quite so many characters 2023-05-28 17:19:30 +03:00
.gitignore Initial commit 2023-02-12 21:25:09 +02:00
.tool-versions Test on Gleam 0.29 2023-05-26 22:58:08 +03:00
CHANGELOG Add HTMLBody encoding mode that doesn't encode quite so many characters 2023-05-28 17:19:30 +03:00
gleam.toml Add HTMLBody encoding mode that doesn't encode quite so many characters 2023-05-28 17:19:30 +03:00
LICENSE Initial commit 2023-02-12 21:25:09 +02:00
manifest.toml Update package for Gleam 0.28 2023-04-15 20:48:41 +03:00
README.md Add HTMLBody encoding mode that doesn't encode quite so many characters 2023-05-28 17:19:30 +03:00

glentities

Package Version Hex Docs

An HTML entity encoder/decoder for Gleam.

Entities can be encoded using named or hex entity references. Named entity references use the WHATWG "Named character references" list available at https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references.

Quick start

import glentities

glentities.encode("</html>", glentities.HTMLBody) // "&lt;/html&gt;"
glentities.encode("</html>", glentities.Named)    // "&lt;&sol;html&gt;"
glentities.encode("</html>", glentities.Hex)      // "&#x3C;&#x2F;html&#x3E;"

glentities.decode("&#x3C;&#x2F;html&#x3E;")       // "</html>"
glentities.decode("&lt;&sol;html&gt;")            // "</html>"

Development

gleam test  # Run the tests

Installation

This package can be added to your Gleam project:

gleam add glentities

and its documentation can be found at https://hexdocs.pm/glentities.