anchor.diff:          <<_:Start/binary, Raw/binary>> ->
               {{data, Raw, false}, S}
       end.
  +
  +
  +tree_to_map({Tag, [], Elts}, TagMap) when is_list(Elts) ->
  +    case lists:any(fun is_element/1, Elts) of
  +        true ->
  +            EltMap = lists:foldr(
  +                fun tree_to_map/2,
  +                #{},
  +                Elts),
  +            TagMap#{
  +                Tag => [ EltMap | maps:get(Tag, TagMap, []) ]
  +            };
  +        false ->
  +            % Leave node, sub elements are values
  +            Vs = map_values(Elts),
  +            TagMap#{
  +                Tag => lists:flatten([ Vs | maps:get(Tag, TagMap, []) ])
  +            }
  +    end;
  +tree_to_map({Tag, Attrs, Elts}, TagMap) when is_list(Elts) ->
  +    case lists:any(fun is_element/1, Elts) of
  +        true ->
  +            EltMap = lists:foldr(
  +                fun tree_to_map/2,
  +                #{},
  +                Elts),
  +            EltMap1 = EltMap#{
  +                <<"@attributes">> => Attrs
  +            },
  +            TagMap#{
  +                Tag => [ EltMap1 | maps:get(Tag, TagMap, []) ]
  +            };
  +        false ->
  +            % Leave node, but with attributes
  +            V = #{
  +                <<"@attributes">> => Attrs,
  +                <<"value">> => map_values(Elts)
  +            },
  +            TagMap#{
  +                Tag => [ V | maps:get(Tag, TagMap, []) ]
  +            }
  +    end;
  +tree_to_map(_, TagMap) ->
  +    TagMap.
  +
  +map_values(Vs) ->
  +    lists:filtermap(fun map_value/1, Vs).
  +
  +map_value(B) when is_binary(B) -> {true, B};
  +map_value(_) -> false.
  +
  +is_element({Tag, Attrs, Elts}) when is_binary(Tag), is_list(Attrs), is_list(Elts) ->
  +    true;
  +is_element(_) ->
  +    false.
   
   
   % @doc Return true when Tag is a html tag.
  
positive.code: -define(INC_COL(S),
          S#decoder{column=1+S#decoder.column,
                    offset=1+S#decoder.offset}).
  -define(INC_LINE(S),
          S#decoder{column=1,
                    line=1+S#decoder.line,
                    offset=1+S#decoder.offset}).
  -define(INC_CHAR(S, C),
          case C of
              $\n ->
  
negative.code:             {{data, Data, Whitespace}, S}
      end.
  
  tokenize_attributes(B, S, Options) ->
      tokenize_attributes(B, S, [], Options).
  
  tokenize_attributes(B, S=#decoder{offset=O}, Acc, Options) ->
      case B of
          <<_:O/binary>> ->
              {lists:reverse(Acc), S};
  