33 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
44 * obtain one at https://mozilla.org/MPL/2.0/
55 *
6- * Copyright (C) 2009-2021 , Peter Johnson (gravatar.com/delphidabbler).
6+ * Copyright (C) 2009-2022 , Peter Johnson (gravatar.com/delphidabbler).
77 *
88 * Provides a class that renders active text as HTML.
99}
@@ -17,9 +17,9 @@ interface
1717
1818uses
1919 // Delphi
20- SysUtils, Graphics, Generics.Collections,
20+ SysUtils,
2121 // Project
22- ActiveText.UMain, UBaseObjects, UCSSBuilder, UHTMLUtils;
22+ ActiveText.UMain, UHTMLUtils;
2323
2424
2525type
@@ -65,6 +65,7 @@ TCSSStyles = class(TObject)
6565 fBuilder: TStringBuilder;
6666 fInBlock: Boolean;
6767 fTagInfoMap: TTagInfoMap;
68+ fLINestingDepth: Cardinal;
6869 procedure InitialiseTagInfoMap ;
6970 procedure InitialiseRender ;
7071 procedure RenderTextElem (Elem: IActiveTextTextElem);
@@ -84,18 +85,14 @@ TCSSStyles = class(TObject)
8485implementation
8586
8687
87- uses
88- // Project
89- UColours, UCSSUtils, UFontHelper, UIStringList;
90-
91-
9288{ TActiveTextHTML }
9389
9490constructor TActiveTextHTML.Create;
9591begin
9692 inherited Create;
9793 fCSSStyles := TCSSStyles.Create;
9894 fBuilder := TStringBuilder.Create;
95+ fLINestingDepth := 0 ;
9996 InitialiseTagInfoMap;
10097end ;
10198
@@ -209,20 +206,24 @@ procedure TActiveTextHTML.RenderBlockActionElem(Elem: IActiveTextActionElem);
209206 case Elem.State of
210207 fsOpen:
211208 begin
209+ if Elem.Kind = ekListItem then
210+ Inc(fLINestingDepth);
212211 fBuilder.Append(MakeOpeningTag(Elem));
213212 fInBlock := True;
214213 end ;
215214 fsClose:
216215 begin
217216 fInBlock := False;
218217 fBuilder.AppendLine(MakeClosingTag(Elem));
218+ if Elem.Kind = ekListItem then
219+ Dec(fLINestingDepth);
219220 end ;
220221 end ;
221222end ;
222223
223224procedure TActiveTextHTML.RenderInlineActionElem (Elem: IActiveTextActionElem);
224225begin
225- if not fInBlock then
226+ if not fInBlock and (fLINestingDepth = 0 ) then
226227 Exit;
227228 case Elem.State of
228229 fsOpen:
@@ -234,7 +235,7 @@ procedure TActiveTextHTML.RenderInlineActionElem(Elem: IActiveTextActionElem);
234235
235236procedure TActiveTextHTML.RenderTextElem (Elem: IActiveTextTextElem);
236237begin
237- if not fInBlock then
238+ if not fInBlock and (fLINestingDepth = 0 ) then
238239 Exit;
239240 fBuilder.Append(THTML.Entities(Elem.Text));
240241end ;
0 commit comments