     end
     do_escape(rest, true, emit, acc)
   end
-
-end+end

    IO.puts IO.ANSI.escape "Hello #[red,bright,green]yes" #=>
    "Hello \e[31m\e[1m\e[32myes\e[0m"
  """
  @doc escape_doc
  @spec escape(String.t) :: String.t
  def escape(string) do
    escape(string, terminal?)
  end

  @doc escape_doc
  @spec escape(String.t, emit :: boolean) :: String.t
  def escape(string, emit) do
    do_escape(string <> "#[reset]", false, emit,[])
  end

  escape_fragment_doc =  """
  Escapes a string coverting named ANSI sequences into actual ANSI codes.

  The format for referring sequences is `#[red]` and `#[red,bright]` (for


    IO.puts IO.ANSI.escape "Hello #[red,bright,green]yes#[reset]" #=>
    "Hello \e[31m\e[1m\e[32myes\e[0m"

  """
  @spec escape_fragment(String.t, emit :: boolean) :: String.t
  def escape_fragment(string, emit // terminal?) do
    do_escape(string, false, emit, [])
  end

  defp do_escape(<< ?#, ?[, rest :: binary >>, false, emit, acc) do
    do_escape_sequence(rest, emit, acc)
