       iex> html = ["other", "<t>a</t>", "<tag a> <naked tag"]
       iex> html |> tokenize() |> tokenized_to_html() == html
       true
+
+      iex> html = ["other", ["<t>a</t>", "<tag a> <naked tag"]]
+      iex> html |> tokenize() |> tokenized_to_html() == html
+      true
+
+      iex> html = ["other", [["<t>a</t>"], "<tag a> </tag>"]]
+      iex> html |> tokenize() |> tokenized_to_html() == html
+      true
+
+      iex> html = ["other", :atom, "<tag a> </tag>"]
+      iex> html |> tokenize() |> tokenized_to_html() == html
+      true
+
+      iex> html = ["other", [:atom, "<tag a> </tag>"]]
+      iex> html |> tokenize() |> tokenized_to_html() == html
+      true
   """
   def tokenized_to_html([]), do: ""
-  def tokenized_to_html([head]) when is_list(head), do: [tokenized_to_html(head)]
+
+  def tokenized_to_html({:tag, tag}), do: "<#{tag}>"
+  def tokenized_to_html({:naked, tag}), do: "<#{tag}"
+  def tokenized_to_html(text) when not is_list(text), do: text
+  # def tokenized_to_html([text]) when not is_list(text), do: text
+
+  def tokenized_to_html([list]) when is_list(list), do: [tokenized_to_html(list)]
   def tokenized_to_html([head | tail]) when is_list(head), do: [tokenized_to_html(head) | tokenized_to_html(tail)]
   def tokenized_to_html([head | tail]), do: tokenized_to_html(head) <> tokenized_to_html(tail)
-  def tokenized_to_html({:tag, tag}), do: "<#{tag}>"
-  def tokenized_to_html({:naked, tag}), do: "<#{tag}"
-  def tokenized_to_html(text), do: text
-
-  # @doc """
-  # Returns the name of the last opened tag.
-
-  #     iex> last_opened_tag("<html><b> </b>")
-  #     "html"
-
-  #     iex> last_opened_tag(" <html> </b><b>")
-  #     "b"
-
-  #     iex> last_opened_tag(" <html> </b><b></c>")
-  #     nil
-
-  #     iex> last_opened_tag("<html><b></b> <tag x")
-  #     "tag"
-
-  #     iex> last_opened_tag("<a><b><c>")
-  #     "c"
-
-  #     iex> last_opened_tag("<a><b></b><c>")
-  #     "c"
-
-  #     iex> last_opened_tag("<a><b></b><c></c>")
-  #     "a"
-
-  #     iex> last_opened_tag("<x><a><b></b><c></c></x>")
-  #     nil
-
-  #     iex> last_opened_tag("<a><b></b><x><c></c></x>")
-  #     "a"
-
-  #     iex> last_opened_tag("<tag>")
-  #     "tag"
-
-  #     iex> last_opened_tag("<tag></tag>")
-  #     nil
-
-  #     iex> last_opened_tag("</tag>")
-  #     nil
-
-  #     iex> last_opened_tag("text")
-  #     nil
-
-  #     iex> last_opened_tag("<a><b></b></a>")
-  #     nil
-  # """
-  # def last_opened_tag(html) do
-  #   tags = tokenize(html) |> Enum.reverse()
-  #   do_last_opened_tag(tags)
-  # end
-
-  # defp do_last_opened_tag([]) do
-  #   nil
-  # end
-  # defp do_last_opened_tag([head | tail]) do
-  #   case head do
-  #     "/" <> tag ->
-  #       case Enum.split_while(tail, &(&1 != tag)) do
-  #         {_, [_ | rest]} -> do_last_opened_tag(rest)
-  #         _ -> nil
-  #       end
-  #     tag -> tag
-  #   end
-  # end
-
-  @non_closing_tags ~w{area base br col embed hr img input keygen link meta param source track wbr}
+
   @doc """
   Injects given attribute to the last found opened (or naked) tag.
 

  def add_attribute(tag, attribute) do
    String.replace(tag, tag_name(tag), "#{tag_name(tag)} #{attribute}", global: false)
  end
end

    iex> inject_attribute_to_last_opened "<tag><tag attr2></tag>", "attr=1"
    {:ok, "<tag attr=1><tag attr2></tag>"}

    iex> inject_attribute_to_last_opened "<tag><br><tag attr2></tag>", "attr=1"
    {:ok, "<tag attr=1><br><tag attr2></tag>"}

    iex> inject_attribute_to_last_opened "<img src", "attr=1"
    {:ok, "<img attr=1 src"}

    iex> inject_attribute_to_last_opened "<hr>", "attr=1"
    {:not_found, "<hr>"}

    iex> inject_attribute_to_last_opened "<tag 1><tag 2><tag 3></tag>", "attr"
    {:ok, "<tag 1><tag attr 2><tag 3></tag>"}

