@@ -65,6 +65,7 @@ TCSSStyles = class(TObject)
65
65
fTagInfoMap: TTagInfoMap;
66
66
fIsStartOfTextLine: Boolean;
67
67
fLINestingDepth: Cardinal;
68
+ fTagGen: THTMLClass;
68
69
const
69
70
IndentMult = 2 ;
70
71
procedure InitialiseTagInfoMap ;
@@ -73,7 +74,7 @@ TCSSStyles = class(TObject)
73
74
function MakeOpeningTag (const Elem: IActiveTextActionElem): string;
74
75
function MakeClosingTag (const Elem: IActiveTextActionElem): string;
75
76
public
76
- constructor Create;
77
+ constructor Create( const ATagGenerator: THTMLClass = nil ) ;
77
78
destructor Destroy; override;
78
79
function Render (ActiveText: IActiveText): string;
79
80
end ;
@@ -87,13 +88,18 @@ implementation
87
88
88
89
{ TActiveTextHTML }
89
90
90
- constructor TActiveTextHTML.Create;
91
+ constructor TActiveTextHTML.Create( const ATagGenerator: THTMLClass) ;
91
92
begin
92
93
inherited Create;
93
94
fCSSStyles := TCSSStyles.Create;
94
95
fBuilder := TStringBuilder.Create;
95
96
fLINestingDepth := 0 ;
96
97
InitialiseTagInfoMap;
98
+ if not Assigned(ATagGenerator) then
99
+ // default behaviour before ATagGenerator parameter was added
100
+ fTagGen := TXHTML
101
+ else
102
+ fTagGen := ATagGenerator;
97
103
end ;
98
104
99
105
destructor TActiveTextHTML.Destroy;
@@ -145,7 +151,7 @@ procedure TActiveTextHTML.InitialiseTagInfoMap;
145
151
function TActiveTextHTML.MakeClosingTag (const Elem: IActiveTextActionElem):
146
152
string;
147
153
begin
148
- Result := TXHTML .ClosingTag(fTagInfoMap[Elem.Kind].Name );
154
+ Result := fTagGen .ClosingTag(fTagInfoMap[Elem.Kind].Name );
149
155
end ;
150
156
151
157
function TActiveTextHTML.MakeOpeningTag (const Elem: IActiveTextActionElem):
@@ -160,7 +166,7 @@ function TActiveTextHTML.MakeOpeningTag(const Elem: IActiveTextActionElem):
160
166
Attrs := THTMLAttributes.Create;
161
167
Attrs.Add(' class' , fCSSStyles.ElemClasses[Elem.Kind])
162
168
end ;
163
- Result := TXHTML .OpeningTag(fTagInfoMap[Elem.Kind].Name , Attrs);
169
+ Result := fTagGen .OpeningTag(fTagInfoMap[Elem.Kind].Name , Attrs);
164
170
end ;
165
171
166
172
function TActiveTextHTML.Render (ActiveText: IActiveText): string;
@@ -242,7 +248,7 @@ function TActiveTextHTML.RenderText(const TextElem: IActiveTextTextElem):
242
248
end
243
249
else
244
250
Result := ' ' ;
245
- Result := Result + TXHTML .Entities(TextElem.Text);
251
+ Result := Result + fTagGen .Entities(TextElem.Text);
246
252
end ;
247
253
248
254
{ TActiveTextHTML.TCSSStyles }
0 commit comments