Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/martinsvalin/html_entities

Elixir module for decoding HTML entities.
https://github.com/martinsvalin/html_entities

Last synced: 7 days ago
JSON representation

Elixir module for decoding HTML entities.

Awesome Lists containing this project

README

        

# HtmlEntities

[![Module Version](https://img.shields.io/hexpm/v/html_entities.svg)](https://hex.pm/packages/html_entities)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/html_entities/)
[![Total Download](https://img.shields.io/hexpm/dt/html_entities.svg)](https://hex.pm/packages/html_entities)
[![License](https://img.shields.io/hexpm/l/html_entities.svg)](https://github.com/martinsvalin/html_entities/blob/master/LICENSE)
[![Last Updated](https://img.shields.io/github/last-commit/martinsvalin/html_entities.svg)](https://github.com/martinsvalin/html_entities/commits/master)

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

Entity names, codepoints and their corresponding characters are copied from
[Wikipedia](https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references).

## Installation

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

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

## Usage

Inside IEx:

```elixir
iex> HtmlEntities.decode("Tom & Jerry")
"Tom & Jerry"
iex> HtmlEntities.decode("¡Ay, caramba!")
"¡Ay, caramba!"
iex> HtmlEntities.encode("<< KAPOW!! >>")
"<< KAPOW!! >>"
```

Inside a module:

```elixir
defmodule EntityTest do
def non_breaking_space do
HtmlEntities.decode("¡")
end
end
```

## License

Copyright (c) 2015 Martin Svalin

This library is MIT licensed. See the [LICENSE](https://github.com/martinsvalin/html_entities/blob/master/LICENSE) for details.