Skip to content

Commit 41844a6

Browse files
committed
Missing text at end of detail pane list items fixed
Code added to track and detect if text is being written inside a list item and to output any inline text as HTML between the end of a nested list and the end of a list item. Such detection is then used in logic that determines when to output such orphaned text. Fixes #82
1 parent d3c57e2 commit 41844a6

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

Src/ActiveText.UHTMLRenderer.pas

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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

1818
uses
1919
// Delphi
20-
SysUtils, Graphics, Generics.Collections,
20+
SysUtils,
2121
// Project
22-
ActiveText.UMain, UBaseObjects, UCSSBuilder, UHTMLUtils;
22+
ActiveText.UMain, UHTMLUtils;
2323

2424

2525
type
@@ -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)
8485
implementation
8586

8687

87-
uses
88-
// Project
89-
UColours, UCSSUtils, UFontHelper, UIStringList;
90-
91-
9288
{ TActiveTextHTML }
9389

9490
constructor TActiveTextHTML.Create;
9591
begin
9692
inherited Create;
9793
fCSSStyles := TCSSStyles.Create;
9894
fBuilder := TStringBuilder.Create;
95+
fLINestingDepth := 0;
9996
InitialiseTagInfoMap;
10097
end;
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;
221222
end;
222223

223224
procedure TActiveTextHTML.RenderInlineActionElem(Elem: IActiveTextActionElem);
224225
begin
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

235236
procedure TActiveTextHTML.RenderTextElem(Elem: IActiveTextTextElem);
236237
begin
237-
if not fInBlock then
238+
if not fInBlock and (fLINestingDepth = 0) then
238239
Exit;
239240
fBuilder.Append(THTML.Entities(Elem.Text));
240241
end;

0 commit comments

Comments
 (0)