Reference

ANSIColoredPrinters.PlainTextPrinterType
PlainTextPrinter(buf::IO; keep_invert=true)

Creates a printer for MIME"text/plain" output.

Arguments

  • buf: A source IO object containing a text with ANSI escape codes.
  • keep_invert: If true, "invert" (SGR code 7) is printed as is.

If keep_invert is false, the color change codes with "invert" enable are reinterpreted as explicit foreground and background color specifications. In this case, the normal inverted foreground color is considered black (SGR code

  1. and the normal inverted background color is considered white (SGR code 47).
source
ANSIColoredPrinters.HTMLPrinterType
HTMLPrinter(buf::IO; keep_invert=false, root_class="", root_tag="pre", callback=nothing)

Creates a printer for MIME"text/html" output.

Arguments

  • buf: A source IO object containing a text with ANSI escape codes.
  • keep_invert: If true, "invert" (SGR code 7) is marked up as class="sgr7".
  • root_class: The class attribute value for the root element.
  • root_tag: The tag name for the root element.
  • callback: A callback method (see below).

If keep_invert is false (default), the color change codes with "invert" enable are reinterpreted as explicit foreground and background color specifications. In this case, the normal inverted foreground color is marked up as class="sgr-39" and the normal inverted background color is marked up as class="sgr-49".

Callback method

callback(io::IO, printer::HTMLPrinter, tag::String, attrs::Dict{Symbol, String})

The callback method will be called just before writing HTML tags.

Callback arguments

  • io: The destination IO object.
  • printer: The HTMLPrinter in use.
  • tag: The HTML tag to be written. For closing tags, they have the prefix "/".
  • attrs: A dictionary consisting of pairs of a Symbol for the attributes (e.g. :class, :style) and the String for its value.

Callback return value

If the return value is nothing, the printer writes the HTML tag to the io according to the tag and the attrs after the call. If the return value is not nothing, this default writing will be prevented.

source