@@ -65,6 +65,7 @@ TCSSStyles = class(TObject)
6565 fTagInfoMap: TTagInfoMap;
6666 fIsStartOfTextLine: Boolean;
6767 fLINestingDepth: Cardinal;
68+ fTagGen: THTMLClass;
6869 const
6970 IndentMult = 2 ;
7071 procedure InitialiseTagInfoMap ;
@@ -73,7 +74,7 @@ TCSSStyles = class(TObject)
7374 function MakeOpeningTag (const Elem: IActiveTextActionElem): string;
7475 function MakeClosingTag (const Elem: IActiveTextActionElem): string;
7576 public
76- constructor Create;
77+ constructor Create( const ATagGenerator: THTMLClass = nil ) ;
7778 destructor Destroy; override;
7879 function Render (ActiveText: IActiveText): string;
7980 end ;
@@ -87,13 +88,18 @@ implementation
8788
8889{ TActiveTextHTML }
8990
90- constructor TActiveTextHTML.Create;
91+ constructor TActiveTextHTML.Create( const ATagGenerator: THTMLClass) ;
9192begin
9293 inherited Create;
9394 fCSSStyles := TCSSStyles.Create;
9495 fBuilder := TStringBuilder.Create;
9596 fLINestingDepth := 0 ;
9697 InitialiseTagInfoMap;
98+ if not Assigned(ATagGenerator) then
99+ // default behaviour before ATagGenerator parameter was added
100+ fTagGen := TXHTML
101+ else
102+ fTagGen := ATagGenerator;
97103end ;
98104
99105destructor TActiveTextHTML.Destroy;
@@ -145,7 +151,7 @@ procedure TActiveTextHTML.InitialiseTagInfoMap;
145151function TActiveTextHTML.MakeClosingTag (const Elem: IActiveTextActionElem):
146152 string;
147153begin
148- Result := TXHTML .ClosingTag(fTagInfoMap[Elem.Kind].Name );
154+ Result := fTagGen .ClosingTag(fTagInfoMap[Elem.Kind].Name );
149155end ;
150156
151157function TActiveTextHTML.MakeOpeningTag (const Elem: IActiveTextActionElem):
@@ -160,7 +166,7 @@ function TActiveTextHTML.MakeOpeningTag(const Elem: IActiveTextActionElem):
160166 Attrs := THTMLAttributes.Create;
161167 Attrs.Add(' class' , fCSSStyles.ElemClasses[Elem.Kind])
162168 end ;
163- Result := TXHTML .OpeningTag(fTagInfoMap[Elem.Kind].Name , Attrs);
169+ Result := fTagGen .OpeningTag(fTagInfoMap[Elem.Kind].Name , Attrs);
164170end ;
165171
166172function TActiveTextHTML.Render (ActiveText: IActiveText): string;
@@ -242,7 +248,7 @@ function TActiveTextHTML.RenderText(const TextElem: IActiveTextTextElem):
242248 end
243249 else
244250 Result := ' ' ;
245- Result := Result + TXHTML .Entities(TextElem.Text);
251+ Result := Result + fTagGen .Entities(TextElem.Text);
246252end ;
247253
248254{ TActiveTextHTML.TCSSStyles }
0 commit comments