Current section
9 Versions
Jump to
Current section
9 Versions
Compare versions
6
files changed
+46
additions
-21
deletions
| @@ -0,0 +1,7 @@ | |
| 1 | + Copyright (c) 2015 Martin Svalin |
| 2 | + |
| 3 | + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
| 4 | + |
| 5 | + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
| 6 | + |
| 7 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| @@ -1,7 +0,0 @@ | |
| 1 | - Copyright (c) 2015 Martin Svalin |
| 2 | - |
| 3 | - Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
| 4 | - |
| 5 | - The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
| 6 | - |
| 7 | - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| @@ -1,5 +1,10 @@ | |
| 1 | - HtmlEntities |
| 2 | - ============ |
| 1 | + # HtmlEntities |
| 2 | + |
| 3 | + [](https://hex.pm/packages/html_entities) |
| 4 | + [](https://hexdocs.pm/html_entities/) |
| 5 | + [](https://hex.pm/packages/html_entities) |
| 6 | + [](https://github.com/martinsvalin/html_entities/blob/master/LICENSE) |
| 7 | + [](https://github.com/martinsvalin/html_entities/commits/master) |
| 3 8 | |
| 4 9 | Elixir module for decoding and encoding HTML entities in a string. |
| 5 10 | |
| @@ -12,13 +17,15 @@ Add the dependency to your `mix.exs` file, then run `mix deps.get`. | |
| 12 17 | |
| 13 18 | ```elixir |
| 14 19 | defp deps do |
| 15 | - [{:html_entities, "~> 0.4"}] |
| 20 | + [ |
| 21 | + {:html_entities, "~> 0.5"} |
| 22 | + ] |
| 16 23 | end |
| 17 24 | ``` |
| 18 25 | |
| 19 26 | ## Usage |
| 20 27 | |
| 21 | - Inside iex: |
| 28 | + Inside IEx: |
| 22 29 | |
| 23 30 | ```elixir |
| 24 31 | iex> HtmlEntities.decode("Tom & Jerry") |
| @@ -38,3 +45,9 @@ defmodule EntityTest do | |
| 38 45 | end |
| 39 46 | end |
| 40 47 | ``` |
| 48 | + |
| 49 | + ## License |
| 50 | + |
| 51 | + Copyright (c) 2015 Martin Svalin |
| 52 | + |
| 53 | + This library is MIT licensed. See the [LICENSE](https://github.com/martinsvalin/html_entities/blob/master/LICENSE) for details. |
| @@ -5,10 +5,10 @@ | |
| 5 5 | {<<"files">>, |
| 6 6 | [<<"lib">>,<<"lib/html_entities">>,<<"lib/html_entities/util.ex">>, |
| 7 7 | <<"lib/html_entities_list.txt">>,<<"lib/html_entities.ex">>,<<"mix.exs">>, |
| 8 | - <<"README.md">>,<<"LICENSE.txt">>]}. |
| 8 | + <<"README.md">>,<<"LICENSE">>]}. |
| 9 9 | {<<"licenses">>,[<<"MIT">>]}. |
| 10 10 | {<<"links">>, |
| 11 11 | [{<<"GitHub">>,<<"https://github.com/martinsvalin/html_entities">>}]}. |
| 12 12 | {<<"name">>,<<"html_entities">>}. |
| 13 13 | {<<"requirements">>,[]}. |
| 14 | - {<<"version">>,<<"0.5.1">>}. |
| 14 | + {<<"version">>,<<"0.5.2">>}. |
| @@ -25,7 +25,7 @@ defmodule HtmlEntities do | |
| 25 25 | |
| 26 26 | @doc "Decode HTML entities in a string." |
| 27 27 | @spec decode(String.t()) :: String.t() |
| 28 | - def decode(string) do |
| 28 | + def decode(string) when is_binary(string) do |
| 29 29 | decode(string, "") |
| 30 30 | end |
| 31 31 | |
| @@ -74,10 +74,10 @@ defmodule HtmlEntities do | |
| 74 74 | |
| 75 75 | @doc "Encode HTML entities in a string." |
| 76 76 | @spec encode(String.t()) :: String.t() |
| 77 | - def encode(string) do |
| 77 | + def encode(string) when is_binary(string) do |
| 78 78 | for <<x <- string>>, into: "" do |
| 79 79 | case x do |
| 80 | - ?' -> "'" |
| 80 | + ?' -> "'" |
| 81 81 | ?" -> """ |
| 82 82 | ?& -> "&" |
| 83 83 | ?< -> "<" |
Loading more files…