3
3
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
4
* obtain one at https://mozilla.org/MPL/2.0/
5
5
*
6
- * Copyright (C) 2009-2021 , Peter Johnson (gravatar.com/delphidabbler).
6
+ * Copyright (C) 2009-2022 , Peter Johnson (gravatar.com/delphidabbler).
7
7
*
8
8
* Provides a class that renders active text as HTML.
9
9
}
@@ -17,9 +17,9 @@ interface
17
17
18
18
uses
19
19
// Delphi
20
- SysUtils, Graphics, Generics.Collections,
20
+ SysUtils,
21
21
// Project
22
- ActiveText.UMain, UBaseObjects, UCSSBuilder, UHTMLUtils;
22
+ ActiveText.UMain, UHTMLUtils;
23
23
24
24
25
25
type
@@ -65,6 +65,7 @@ TCSSStyles = class(TObject)
65
65
fBuilder: TStringBuilder;
66
66
fInBlock: Boolean;
67
67
fTagInfoMap: TTagInfoMap;
68
+ fLINestingDepth: Cardinal;
68
69
procedure InitialiseTagInfoMap ;
69
70
procedure InitialiseRender ;
70
71
procedure RenderTextElem (Elem: IActiveTextTextElem);
@@ -84,18 +85,14 @@ TCSSStyles = class(TObject)
84
85
implementation
85
86
86
87
87
- uses
88
- // Project
89
- UColours, UCSSUtils, UFontHelper, UIStringList;
90
-
91
-
92
88
{ TActiveTextHTML }
93
89
94
90
constructor TActiveTextHTML.Create;
95
91
begin
96
92
inherited Create;
97
93
fCSSStyles := TCSSStyles.Create;
98
94
fBuilder := TStringBuilder.Create;
95
+ fLINestingDepth := 0 ;
99
96
InitialiseTagInfoMap;
100
97
end ;
101
98
@@ -209,20 +206,24 @@ procedure TActiveTextHTML.RenderBlockActionElem(Elem: IActiveTextActionElem);
209
206
case Elem.State of
210
207
fsOpen:
211
208
begin
209
+ if Elem.Kind = ekListItem then
210
+ Inc(fLINestingDepth);
212
211
fBuilder.Append(MakeOpeningTag(Elem));
213
212
fInBlock := True;
214
213
end ;
215
214
fsClose:
216
215
begin
217
216
fInBlock := False;
218
217
fBuilder.AppendLine(MakeClosingTag(Elem));
218
+ if Elem.Kind = ekListItem then
219
+ Dec(fLINestingDepth);
219
220
end ;
220
221
end ;
221
222
end ;
222
223
223
224
procedure TActiveTextHTML.RenderInlineActionElem (Elem: IActiveTextActionElem);
224
225
begin
225
- if not fInBlock then
226
+ if not fInBlock and (fLINestingDepth = 0 ) then
226
227
Exit;
227
228
case Elem.State of
228
229
fsOpen:
@@ -234,7 +235,7 @@ procedure TActiveTextHTML.RenderInlineActionElem(Elem: IActiveTextActionElem);
234
235
235
236
procedure TActiveTextHTML.RenderTextElem (Elem: IActiveTextTextElem);
236
237
begin
237
- if not fInBlock then
238
+ if not fInBlock and (fLINestingDepth = 0 ) then
238
239
Exit;
239
240
fBuilder.Append(THTML.Entities(Elem.Text));
240
241
end ;
0 commit comments