     col = col
           |> String.replace(~r/\\ \|/x, "|")
           |> handle_links
-          |> handle_inline(true, nil, [], [], options)
+          |> handle_inline(options)
     {col, length_without_escape(col, 0)}
   end
 

    lines
    |> Enum.join(" ")
    |> handle_links
    |> handle_inline(true, nil, [], [], options)
    |> String.split(~r{\s})
    |> write_with_wrap(options[:width] - byte_size(indent), indent, no_wrap)


    Regex.replace(~r{\[(.*?)\]\((.*?)\)}, text, "\\1 (\\2)")
  end


  # We have four entries: **, *, _ and `.
  #
  # The first three behave the same while the last one is simpler
  # when it comes to delimiters. But, since the first has two
  # characters, we need to handle 3 cases:
  #
  # 1. **
  # 2. _ and *
  # 3. `
  #
  # Where the first two should have the same code but match differently.
  @single [?_, ?*]

  # Characters that can mark the beginning or the end of a word.
  # Only support the most common ones at this moment.
  @delimiters [?\s, ?', ?", ?!, ?@, ?#, ?$, ?%, ?^, ?&, ?-, ?+, ?(, ?), ?[, ?], ?{, ?}, ?<, ?>]

  # Inline start

  defp handle_inline(<<?*, ?*, rest :: binary>>, options) do
    handle_inline(rest, ?d, ["**"], [], options)
  end

  defp handle_inline(<<mark, rest :: binary>>, options) when mark in @single do
    handle_inline(rest, mark, [<<mark>>], [], options)
  end

  defp handle_inline(rest, options) do
    handle_inline(rest, nil, [], [], options)
  end

  # Inline delimiters

  defp handle_inline(<<delimiter, ?*, ?*, rest :: binary>>, nil, buffer, acc, options)
      when rest != "" and delimiter in @delimiters do
    handle_inline(rest, ?d, ["**"], [delimiter, Enum.reverse(buffer)|acc], options)
  end

  defp handle_inline(<<delimiter, mark, rest :: binary>>, nil, buffer, acc, options)
      when rest != "" and delimiter in @delimiters and mark in @single do
    handle_inline(rest, mark, [<<mark>>], [delimiter, Enum.reverse(buffer)|acc], options)
  end

  defp handle_inline(<<?`, rest :: binary>>, nil, buffer, acc, options)
      when rest != "" do
    handle_inline(rest, ?`, ["`"], [Enum.reverse(buffer)|acc], options)
  end

  # Clauses for handling escape

  defp handle_inline(<<?\\, ?\\, ?*, ?*, rest :: binary>>, nil, buffer, acc, options)
      when rest != "" do
    handle_inline(rest, ?d, ["**"], [?\\, Enum.reverse(buffer)|acc], options)
  end

  defp handle_inline(<<?\\, ?\\, mark, rest :: binary>>, nil, buffer, acc, options)
      when rest != "" and mark in @single do
    handle_inline(rest, mark, [<<mark>>], [?\\, Enum.reverse(buffer)|acc], options)
  end

  defp handle_inline(<<?\\, ?\\, rest :: binary>>, limit, buffer, acc, options) do
    handle_inline(rest, limit, [?\\|buffer], acc, options)
  end

  # An escape is not valid inside `
  defp handle_inline(<<?\\, mark, rest :: binary>>, limit, buffer, acc, options)
      when not(mark == limit and mark == ?`) do
    handle_inline(rest, limit, [mark|buffer], acc, options)
  end

  # Inline end

  defp handle_inline(<<?*, ?*, delimiter, rest :: binary>>, ?d, buffer, acc, options)
      when delimiter in @delimiters do
    handle_inline(<<delimiter, rest :: binary>>, nil, [], [inline_buffer(buffer, options)|acc], options)
  end

  defp handle_inline(<<mark, delimiter, rest :: binary>>, mark, buffer, acc, options)
      when delimiter in @delimiters and mark in @single do
    handle_inline(<<delimiter, rest :: binary>>, nil, [], [inline_buffer(buffer, options)|acc], options)
  end

  defp handle_inline(<<?*, ?*, rest:: binary>>, ?d, buffer, acc, options)
      when rest == "" do
    handle_inline(<<>>, nil, [], [inline_buffer(buffer, options)|acc], options)
  end

  defp handle_inline(<<mark, rest :: binary>>, mark, buffer, acc, options)
      when rest == "" and mark in @single do
    handle_inline(<<>>, nil, [], [inline_buffer(buffer, options)|acc], options)
  end

  defp handle_inline(<<?`, rest :: binary>>, ?`, buffer, acc, options) do
    handle_inline(rest, nil, [], [inline_buffer(buffer, options)|acc], options)
  end

  # Catch all

  defp handle_inline(<<char, rest :: binary>>, mark, buffer, acc, options) do
    handle_inline(rest, mark, [char|buffer], acc, options)
  end

  defp handle_inline(<<>>, _mark, buffer, acc, _options) do
    IO.iodata_to_binary Enum.reverse([Enum.reverse(buffer)|acc])
  end

