html_entities

Decode and encode HTML entities in a string.


License
MIT

Documentation

HtmlEntities

Module Version Hex Docs Total Download License Last Updated

Elixir module for decoding and encoding HTML entities in a string.

Entity names, codepoints and their corresponding characters are copied from Wikipedia.

Installation

Add the dependency to your mix.exs file, then run mix deps.get.

defp deps do
  [
    {:html_entities, "~> 0.5"}
  ]
end

Usage

Inside IEx:

iex> HtmlEntities.decode("Tom & Jerry")
"Tom & Jerry"
iex> HtmlEntities.decode("¡Ay, caramba!")
"¡Ay, caramba!"
iex> HtmlEntities.encode("<< KAPOW!! >>")
"&lt;&lt; KAPOW!! &gt;&gt;"

Inside a module:

defmodule EntityTest do
  def non_breaking_space do
    HtmlEntities.decode("&#161;")
  end
end

License

Copyright (c) 2015 Martin Svalin

This library is MIT licensed. See the LICENSE for details.