anchor.diff:              to_tokens([{T1, C1}, {Tag, R1} | Rest],
                         [{start_tag, T1, A1, false} | Acc])
       end;
  -to_tokens([{Tag, [L | R1]} | Rest], Acc) when is_list(L) ->
  -    to_tokens([{Tag, R1} | Rest], [{data, L, false} | Acc]).
  +to_tokens([{Tag0, [L | R1]} | Rest], Acc) when is_list(L) ->
  +    Tag = to_tag(Tag0),
  +    to_tokens([{Tag, R1} | Rest], [{data, L, false} | Acc]);
  +to_tokens([{Tag0, [B | R1]} | Rest], Acc) when is_binary(B) ->
  +    Tag = to_tag(Tag0),
  +    to_tokens([{Tag, R1} | Rest], [{data, binary_to_list(B), false} | Acc]).
   
   test_tokens() ->
       [{start_tag, "foo", [{"bar", "baz"},
  
positive.code: %% @doc Transform the input UTF-8 HTML into a token stream.
  tokens(Input) when is_binary(Input) ->
      tokens(binary_to_list(Input), #decoder{}, []);
  tokens(Input) ->
      tokens(Input, #decoder{}, []).
  
  %% @spec to_tokens(html_node()) -> [html_token()]
  %% @doc Convert a html_node() tree to a list of tokens.
  to_tokens({Tag, Attrs, Acc}) ->
      to_tokens([{Tag, Acc}], [{start_tag, Tag, Attrs, is_singleton(Tag)}]).
  
  %% @spec to_html([html_token()]) -> iolist()
  %% @doc Convert a list of html_token() to a HTML document.
  to_html(Tokens) ->
      to_html(Tokens, []).
  
  %% @spec escape(S::string()) -> string()
  %% @doc Escape a string such that it's safe for HTML (amp; lt; gt;).
  escape(S) ->
      escape(S, []).
  
  %% @spec escape(S::string()) -> string()
  %% @doc Escape a string such that it's safe for HTML attrs
  %%      (amp; lt; gt; quot;).
  escape_attr(S) ->
      escape_attr(S, []).
  
  %% @spec test() -> ok
  
negative.code: escape_attr([C | Rest], Acc) ->
      escape_attr(Rest, [C | Acc]).
  
  to_tag(A) when is_atom(A) ->
      atom_to_list(A);
  to_tag(L) ->
      L.
  
  to_tokens([], Acc) ->
      lists:reverse(Acc);
  to_tokens([{Tag, []} | Rest], Acc) ->
      to_tokens(Rest, [{end_tag, to_tag(Tag)} | Acc]);
  to_tokens([{Tag0, [{T0} | R1]} | Rest], Acc) ->
      %% Allow {br}
      to_tokens([{Tag0, [{T0, [], []} | R1]} | Rest], Acc);
  to_tokens([{Tag0, [{T0, C0} | R1]} | Rest], Acc) ->
      %% Allow {p, ["content"]}
      to_tokens([{Tag0, [{T0, [], C0} | R1]} | Rest], Acc);
  to_tokens([{Tag0, [{T0, A1, C0} | R1]} | Rest], Acc) when is_binary(C0) ->
      %% Allow {"p", [{"class", "foo"}], <<"content">>}
      to_tokens([{Tag0, [{T0, A1, binary_to_list(C0)} | R1]} | Rest], Acc);
  to_tokens([{Tag0, [{T0, A1, C0=[C | _]} | R1]} | Rest], Acc)
    when is_integer(C) ->
      %% Allow {"p", [{"class", "foo"}], "content"}
      to_tokens([{Tag0, [{T0, A1, [C0]} | R1]} | Rest], Acc);
  to_tokens([{Tag0, [{T0, A1, C1} | R1]} | Rest], Acc) ->
      %% Native {"p", [{"class", "foo"}], ["content"]}
      Tag = to_tag(Tag0),
      T1 = to_tag(T0),
      case is_singleton(T1) of
          true ->
              to_tokens([{Tag, R1} | Rest], [{start_tag, T1, A1, true} | Acc]);
  