Skip to content

Instantly share code, notes, and snippets.

@JLarky
Created April 28, 2017 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JLarky/d10ffdce805d39878929cf4c46183bee to your computer and use it in GitHub Desktop.
Save JLarky/d10ffdce805d39878929cf4c46183bee to your computer and use it in GitHub Desktop.
Encode html entities or escape html with Elixir and xmerl Erlang module
defp html_encode(text) do
[_ | xml] = :xmerl.export_simple([{:xmlText, [], 0, [], text, :text}], :xmerl_xml)
:erlang.iolist_to_binary(xml)
end
@Stratus3D
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment