AnsiToHTML v0.3.0 AnsiToHTML View Source

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.

Link to this section 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.

Link to this section Functions

Link to this function

generate_html(input, theme \\ %AnsiToHTML.Theme{}) View Source
generate_html(String.t(), AnsiToHTML.Theme.t()) :: String.t()

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

Returns String.t.

Examples

iex> AnsiToHTML.generate_html(inspect :hello, pretty: true, syntax_colors: [atom: :green])
"<pre style=\"font-family: monospace; font-size: 12px; padding: 4px; background-color: black; color: white;\"><span style=\"color: green;\">:hello</span></pre>"
Link to this function

generate_phoenix_html(input, theme \\ %AnsiToHTML.Theme{}) View Source
generate_phoenix_html(String.t(), AnsiToHTML.Theme.t()) :: 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(inspect :hello, pretty: true, syntax_colors: [atom: :green])
{:safe,
[60, "pre",
  [[32, "style", 61, 34,
    "font-family: monospace; font-size: 12px; padding: 4px; background-color: black; color: white;",
    34]], 62,
  [[60, "span", [[32, "style", 61, 34, "color: green;", 34]], 62, [":hello"],
    60, 47, "span", 62]], 60, 47, "pre", 62]}