AnsiToHTML v0.1.0 AnsiToHTML
AnsiToHTML is a small library to convert ANSI Styling codes to HTML using phoenix_html.
The library is not solely intented for use with Phoenix and can be easily used without it.
Summary
Functions
Generates a new HTML string based on the passed ANSI string
Generates a new Phoenix HTML tag based on the passed ANSI string
Functions
Generates a new HTML string based on the passed ANSI string.
Returns String.t.
Examples
iex> AnsiToHTML.generate_html("[34m[[0m[32m:hello[0m[34m][0m")
"<pre><span style=\"color: blue;color: green;color: blue\">[:hello]</span></pre>"
iex> AnsiToHTML.generate_html("[34m[[0m[32m:hello[0m[34m][0m", :div)
"<div><span style=\"color: blue;color: green;color: blue\">[:hello]</span></div>"
generate_phoenix_html(input, container_tag \\ :pre)
generate_phoenix_html(String.t, atom) :: Phoenix.HTML.Tag.t
Generates a new Phoenix HTML tag based on the passed ANSI string.
Returns Phoenix.HTML.Tag.t.
Examples
iex> AnsiToHTML.generate_phoenix_html("[34m[[0m[32m:hello[0m[34m][0m")
{:safe,
[60, "pre", [], 62,
[[60, "span",
[[32, "style", 61, 34, "color: blue;color: green;color: blue", 34]], 62,
["[", ":hello", "]"], 60, 47, "span", 62]], 60, 47, "pre", 62]}
iex> AnsiToHTML.generate_phoenix_html("[34m[[0m[32m:hello[0m[34m][0m", :div)
{:safe,
[60, "div", [], 62,
[[60, "span",
[[32, "style", 61, 34, "color: blue;color: green;color: blue", 34]], 62,
["[", ":hello", "]"], 60, 47, "span", 62]], 60, 47, "div", 62]}