Skip to content

yuriploc/html_entities

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HtmlEntities

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.4"}]
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

About

Elixir module for decoding HTML entities.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Elixir 100.0%