anchor.diff:  end;
   
   type
  -  TEditorHtmlTagsArray = array of record
  +
  +  { TEditorHtmlTagRecord }
  +
  +  TEditorHtmlTagRecord = record
       bClosing: boolean;
  -    sTagName: UnicodeString;
  -  end;
  +    sTagName: string[30];
  +    class operator =(const a, b: TEditorHtmlTagRecord): boolean;
  +  end;
  +
  +  TEditorHtmlTagList = specialize TFPGList<TEditorHtmlTagRecord>;
   
   procedure EditorFindHtmlTagsInText(const AText: UnicodeString;
  -  out ARes: TEditorHtmlTagsArray; AllowSingletonTags: boolean);
  +  AList: TEditorHtmlTagList; AllowSingletonTags: boolean);
   const
     cRegexTags = '<(/?)([\w\-:]+).*?>';
   var
     obj: TRegExpr;
     sTag: UnicodeString;
     bClosing: boolean;
  -begin
  -  SetLength(ARes, 0);
  +  TagRecord: TEditorHtmlTagRecord;
  +begin
  +  AList.Clear;
     obj:= TRegExpr.Create(cRegexTags);
     try
       obj.Compile;
  
positive.code:   ATSynEdit_Finder,
    ATSynEdit_Cmp_HTML,
    ATSynEdit_RegExpr,
    ATStrings,
    ATStringProc,
    ATStringProc_Separator,
  
negative.code:       if not AllowSingletonTags then
          if not IsTagNeedsClosingTag(sTag) then Continue;
  
        TagRecord.bClosing:= bClosing;
        TagRecord.sTagName:= sTag;
        AList.Add(TagRecord);
      until not obj.ExecNext;
    finally
      obj.Free;
    end;
  end;
  
  function EditorFindHtmlLastOpenedTagInText(const AText: UnicodeString): string;
  var
    tags: TEditorHtmlTagList;
    i, j: integer;
  begin
    Result:= '';
    tags:= TEditorHtmlTagList.Create;
    try
      EditorFindHtmlTagsInText(AText, tags, false);
  
      //delete pairs <tag> - </tag>
      for i:= tags.Count-1 downto 0 do
      begin
        if not tags[i].bClosing then
          for j:= i+1 to tags.Count-1 do
            if tags[j].bClosing and SameText(tags[i].sTagName, tags[j].sTagName) then
            begin
              tags.Delete(j);
              tags.Delete(i);
              Break;
            end;
      end;
  
      //take last opened tag
      for i:= tags.Count-1 downto 0 do
        if not tags[i].bClosing then
          exit(tags[i].sTagName);
    finally
      FreeAndNil(tags);
    end;
  end;
  
  
  