anchor.diff:                  {start_tag,<<"div">>,[{<<"class">>,<<"c">>}],false},
                   {end_tag,<<"div">>},
                   {end_tag,<<"div">>}],
  -    {<<"html">>, [],
  -     [{<<"head">>, [], []},
  -      {<<"body">>, [],
  -       [{<<"div">>, [{<<"class">>, <<"a">>}], [{<<"a">>, [{<<"name">>, <<"#anchor">>}], []}]},
  -        {<<"div">>, [{<<"class">>, <<"b">>}], [{<<"div">>, [{<<"class">>, <<"c">>}], []}]}
  -       ]}]} = parse_tokens(D4),
  +    ?assertEqual(
  +       {<<"html">>, [],
  +        [{<<"head">>, [], []},
  +         {<<"body">>, [],
  +          [{<<"div">>, [{<<"class">>, <<"a">>}], [{<<"a">>, [{<<"name">>, <<"#anchor">>}], []}]},
  +           {<<"div">>, [{<<"class">>, <<"b">>}], [{<<"div">>, [{<<"class">>, <<"c">>}], []}]}
  +          ]}]},
  +       parse_tokens(D4)),
       D5 = [{start_tag,<<"html">>,[],false},
             {data,<<"\n">>,true},
             {data,<<"boo">>,false},
             {data,<<"hoo">>,false},
             {data,<<"\n">>,true},
             {end_tag,<<"html">>}],
  -    {<<"html">>, [], [<<"\nboohoo\n">>]} = parse_tokens(D5),
  +    ?assertEqual(
  +       {<<"html">>, [], [<<"\nboohoo\n">>]},
  +       parse_tokens(D5)),
       D6 = [{start_tag,<<"html">>,[],false},
             {data,<<"\n">>,true},
             {data,<<"\n">>,true},
             {end_tag,<<"html">>}],
  -    {<<"html">>, [], []} = parse_tokens(D6),
  +    ?assertEqual(
  +       {<<"html">>, [], []},
  +       parse_tokens(D6)),
       D7 = [{start_tag,<<"html">>,[],false},
             {start_tag,<<"ul">>,[],false},
             {start_tag,<<"li">>,[],false},
  
positive.code: -ifdef(TEST).
  
  to_html_test() ->
      Expect = <<"<html><head><title>hey!</title></head><body><p class=\"foo\">what's up<br /></p><div>sucka</div><!-- comment! --></body></html>">>,
      Expect = iolist_to_binary(
                 to_html({html, [],
                          [{<<"head">>, [],
                            [{title, <<"hey!">>}]},
                           {body, [],
                            [{p, [{class, foo}], [<<"what's">>, <<" up">>, {br}]},
                             {'div', <<"sucka">>},
                             {comment, <<" comment! ">>}]}]})),
      Expect1 = <<"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">">>,
      Expect1 = iolist_to_binary(
                  to_html({doctype,
                           [<<"html">>, <<"PUBLIC">>,
                            <<"-//W3C//DTD XHTML 1.0 Transitional//EN">>,
                            <<"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">>]})),
  
      Expect2 = <<"<html><?xml:namespace prefix=\"o\" ns=\"urn:schemas-microsoft-com:office:office\"?></html>">>,
  
      Expect2 = iolist_to_binary(
                  to_html({<<"html">>,[],
                           [{pi, <<"xml:namespace">>,
                            [{<<"prefix">>,<<"o">>},
                             {<<"ns">>,<<"urn:schemas-microsoft-com:office:office">>}]}]})),
      ok.
  
  escape_test() ->
      <<"&amp;quot;\"word &lt;&lt;up!&amp;quot;">> =
          escape(<<"&quot;\"word <<up!&quot;">>),
      ok.
  
  escape_attr_test() ->
      <<"&amp;quot;&quot;word &lt;&lt;up!&amp;quot;">> =
          escape_attr(<<"&quot;\"word <<up!&quot;">>),
      ok.
  
  tokens_test() ->
      [{start_tag, <<"foo">>, [{<<"bar">>, <<"baz">>},
                               {<<"wibble">>, <<"wibble">>},
                               {<<"alice">>, <<"bob">>}], true}] =
          tokens(<<"<foo bar=baz wibble='wibble' alice=\"bob\"/>">>),
      [{start_tag, <<"foo">>, [{<<"bar">>, <<"baz">>},
                               {<<"wibble">>, <<"wibble">>},
                               {<<"alice">>, <<"bob">>}], true}] =
          tokens(<<"<foo bar=baz wibble='wibble' alice=bob/>">>),
      [{comment, <<"[if lt IE 7]>\n<style type=\"text/css\">\n.no_ie { display: none; }\n</style>\n<![endif]">>}] =
          tokens(<<"<!--[if lt IE 7]>\n<style type=\"text/css\">\n.no_ie { display: none; }\n</style>\n<![endif]-->">>),
      [{start_tag, <<"script">>, [{<<"type">>, <<"text/javascript">>}], false},
       {data, <<" A= B <= C ">>, false},
       {end_tag, <<"script">>}] =
          tokens(<<"<script type=\"text/javascript\"> A= B <= C </script>">>),
      [{start_tag, <<"script">>, [{<<"type">>, <<"text/javascript">>}], false},
       {data, <<" A= B <= C ">>, false},
       {end_tag, <<"script">>}] =
          tokens(<<"<script type =\"text/javascript\"> A= B <= C </script>">>),
      [{start_tag, <<"script">>, [{<<"type">>, <<"text/javascript">>}], false},
       {data, <<" A= B <= C ">>, false},
       {end_tag, <<"script">>}] =
          tokens(<<"<script type = \"text/javascript\"> A= B <= C </script>">>),
      [{start_tag, <<"script">>, [{<<"type">>, <<"text/javascript">>}], false},
       {data, <<" A= B <= C ">>, false},
       {end_tag, <<"script">>}] =
          tokens(<<"<script type= \"text/javascript\"> A= B <= C </script>">>),
      [{start_tag, <<"textarea">>, [], false},
       {data, <<"<html></body>">>, false},
       {end_tag, <<"textarea">>}] =
          tokens(<<"<textarea><html></body></textarea>">>),
      [{pi, <<"xml:namespace">>,
       [{<<"prefix">>,<<"o">>},
       {<<"ns">>,<<"urn:schemas-microsoft-com:office:office">>}]}]=
          tokens(<<"<?xml:namespace prefix=\"o\" ns=\"urn:schemas-microsoft-com:office:office\"?>">>),
      ok.
  
  parse_test() ->
  
negative.code:           {data,<<"asdf">>,false},
            {end_tag,<<"ul">>},
            {end_tag,<<"html">>}],
      ?assertEqual(
         {<<"html">>, [],
          [{<<"ul">>, [],
            [{<<"li">>, [], [<<"word">>]},
             {<<"li">>, [], [<<"up">>]},
             {<<"li">>, [], [<<"fdsa">>,{<<"br">>, [], []}, <<"asdf">>]}]}]},
         parse_tokens(D7)),
      ok.
  
  destack_test() ->
  