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

generate_html(input, container_tag \\ :pre)
generate_html(String.t, atom) :: String.t

Generates a new HTML string based on the passed ANSI string.

Returns String.t.

Examples

iex> AnsiToHTML.generate_html("[:hello]")
"<pre><span style=\"color: blue;color: green;color: blue\">[:hello]</span></pre>"

iex> AnsiToHTML.generate_html("[:hello]", :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("[:hello]")
{: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("[:hello]", :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]}