Skip to content

Commit fc1b87a

Browse files
committed
Add new THML5 & TXHTML classes & reimplement THTML
THTML was re-implemented as a static abstract class instead of a record. It now acts as an abstract base template class for two new static classes - TXHTML and THML5. TXHTML was added as drop-in replacement for the original implementation of THTML. Since the original THTML generated XML compliant tags, this new name is more accurate. All code that called THML was changed to call TXHTML instead. TXHTML was implemented without any change of interface to THTML, despite the fact that the original THML was a record and TXHTML is a class. THTML5 was added as another static class that descends from THTML. This class generates HTML 5 compliant tags. A new class reference to THTML derived types was added, named THTMLClass.
1 parent 1b54e43 commit fc1b87a

11 files changed

+109
-78
lines changed

Src/ActiveText.UHTMLRenderer.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ procedure TActiveTextHTML.InitialiseTagInfoMap;
145145
function TActiveTextHTML.MakeClosingTag(const Elem: IActiveTextActionElem):
146146
string;
147147
begin
148-
Result := THTML.ClosingTag(fTagInfoMap[Elem.Kind].Name);
148+
Result := TXHTML.ClosingTag(fTagInfoMap[Elem.Kind].Name);
149149
end;
150150

151151
function TActiveTextHTML.MakeOpeningTag(const Elem: IActiveTextActionElem):
@@ -160,7 +160,7 @@ function TActiveTextHTML.MakeOpeningTag(const Elem: IActiveTextActionElem):
160160
Attrs := THTMLAttributes.Create;
161161
Attrs.Add('class', fCSSStyles.ElemClasses[Elem.Kind])
162162
end;
163-
Result := THTML.OpeningTag(fTagInfoMap[Elem.Kind].Name, Attrs);
163+
Result := TXHTML.OpeningTag(fTagInfoMap[Elem.Kind].Name, Attrs);
164164
end;
165165

166166
function TActiveTextHTML.Render(ActiveText: IActiveText): string;
@@ -242,7 +242,7 @@ function TActiveTextHTML.RenderText(const TextElem: IActiveTextTextElem):
242242
end
243243
else
244244
Result := '';
245-
Result := Result + THTML.Entities(TextElem.Text);
245+
Result := Result + TXHTML.Entities(TextElem.Text);
246246
end;
247247

248248
{ TActiveTextHTML.TCSSStyles }

Src/Browser.UHighlighter.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function TWBHighlighter.HighlightWord(const Word: string;
194194
begin
195195
// Apply highlight to found text by spanning it with highlight style
196196
SpanAttrs := THTMLAttributes.Create('style', fHighLightStyle);
197-
Range.pasteHTML(THTML.CompoundTag('span', SpanAttrs, Range.htmlText));
197+
Range.pasteHTML(TXHTML.CompoundTag('span', SpanAttrs, Range.htmlText));
198198
Inc(Result);
199199
end
200200
else

Src/FmAboutDlg.pas

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,15 @@ function TAboutDlg.ContribListHTML(ContribList: IStringList):
312312
begin
313313
for Contributor in ContribList do
314314
Result := Result
315-
+ THTML.CompoundTag('div', THTML.Entities(Contributor))
315+
+ TXHTML.CompoundTag('div', TXHTML.Entities(Contributor))
316316
+ EOL;
317317
end
318318
else
319319
begin
320320
// List couldn't be found: display warning message
321321
DivAttrs := THTMLAttributes.Create('class', 'warning');
322-
Result := THTML.CompoundTag(
323-
'div', DivAttrs, THTML.Entities(sNoContributors)
322+
Result := TXHTML.CompoundTag(
323+
'div', DivAttrs, TXHTML.Entities(sNoContributors)
324324
);
325325
end;
326326
end;
@@ -484,15 +484,15 @@ procedure TAboutDlg.InitHTMLFrames;
484484
'DBLicense',
485485
StrIf(
486486
fMetaData.GetLicenseInfo.URL <> '',
487-
THTML.CompoundTag(
487+
TXHTML.CompoundTag(
488488
'a',
489489
THTMLAttributes.Create([
490490
THTMLAttribute.Create('href', fMetaData.GetLicenseInfo.URL),
491491
THTMLAttribute.Create('class', 'external-link')
492492
]),
493-
THTML.Entities(fMetaData.GetLicenseInfo.Name)
493+
TXHTML.Entities(fMetaData.GetLicenseInfo.Name)
494494
),
495-
THTML.Entities(fMetaData.GetLicenseInfo.Name)
495+
TXHTML.Entities(fMetaData.GetLicenseInfo.Name)
496496
)
497497
);
498498
Tplt.ResolvePlaceholderHTML(

Src/FmCompErrorDlg.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ function TCompErrorDlg.TCompilerLog.LogListHTML: string;
341341
begin
342342
Result := '';
343343
for Line in fLog do
344-
Result := Result + THTML.CompoundTag('li', THTML.Entities(Line)) + EOL;
344+
Result := Result + TXHTML.CompoundTag('li', TXHTML.Entities(Line)) + EOL;
345345
end;
346346

347347
end.

Src/UCompResHTML.pas

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class function TCompResHTML.CompileResultsTableRows(Compilers: ICompilers;
9999
Compiler: ICompiler; // each supported compiler
100100
begin
101101
// Initialise HTML for two rows of table and resulting table HTML
102-
Row1 := THTML.OpeningTag('tr');
103-
Row2 := THTML.OpeningTag('tr');
102+
Row1 := TXHTML.OpeningTag('tr');
103+
Row2 := TXHTML.OpeningTag('tr');
104104
// Add to each table row for each compiler: compiler name in row 1 and LED
105105
// image representing compile result in row 2
106106
for Compiler in Compilers do
@@ -111,8 +111,8 @@ class function TCompResHTML.CompileResultsTableRows(Compilers: ICompilers;
111111
Row2 := Row2 + ResultCell(CompileResults[Compiler.GetID]) + EOL;
112112
end;
113113
// Close the two rows
114-
Row1 := Row1 + THTML.ClosingTag('tr');
115-
Row2 := Row2 + THTML.ClosingTag('tr');
114+
Row1 := Row1 + TXHTML.ClosingTag('tr');
115+
Row2 := Row2 + TXHTML.ClosingTag('tr');
116116
// Return HTML of two rows
117117
Result := Row1 + Row2;
118118
end;
@@ -123,30 +123,30 @@ class function TCompResHTML.EmptyTableRows: string;
123123
sMessage = 'Results for all compilers have been hidden.';
124124
sHelpText = 'More information';
125125
begin
126-
Result := THTML.CompoundTag(
126+
Result := TXHTML.CompoundTag(
127127
'tr',
128-
THTML.CompoundTag(
128+
TXHTML.CompoundTag(
129129
'th',
130-
THTML.CompoundTag(
130+
TXHTML.CompoundTag(
131131
'span',
132132
THTMLAttributes.Create('class', 'warning'),
133-
THTML.Entities(sHeading)
133+
TXHTML.Entities(sHeading)
134134
)
135135
)
136136
) +
137-
THTML.CompoundTag(
137+
TXHTML.CompoundTag(
138138
'tr',
139-
THTML.CompoundTag(
139+
TXHTML.CompoundTag(
140140
'td',
141-
THTML.Entities(sMessage)
141+
TXHTML.Entities(sMessage)
142142
+ ' ' +
143-
THTML.CompoundTag(
143+
TXHTML.CompoundTag(
144144
'a',
145145
THTMLAttributes.Create([
146146
THTMLAttribute.Create('href', 'help:AllCompilersHidden'),
147147
THTMLAttribute.Create('class', 'help-link')
148148
]),
149-
THTML.Entities(sHelpText)
149+
TXHTML.Entities(sHelpText)
150150
)
151151
+ '.'
152152
)
@@ -172,7 +172,7 @@ class function TCompResHTML.ImageTag(const CompRes: TCompileResult): string;
172172
);
173173
Attrs.Add('title', CompResImgInfo[CompRes].Title);
174174
// Create tag
175-
Result := THTML.SimpleTag('img', Attrs);
175+
Result := TXHTML.SimpleTag('img', Attrs);
176176
end;
177177

178178
class function TCompResHTML.NameCell(const Compiler: ICompiler): string;
@@ -181,14 +181,14 @@ class function TCompResHTML.NameCell(const Compiler: ICompiler): string;
181181
begin
182182
// Any spaces in compiler name replaced by <br /> tags
183183
CompilerNameHTML := StrReplace(
184-
THTML.Entities(Compiler.GetName), ' ', THTML.SimpleTag('br')
184+
TXHTML.Entities(Compiler.GetName), ' ', TXHTML.SimpleTag('br')
185185
);
186-
Result := THTML.CompoundTag('th', CompilerNameHTML);
186+
Result := TXHTML.CompoundTag('th', CompilerNameHTML);
187187
end;
188188

189189
class function TCompResHTML.ResultCell(const CompRes: TCompileResult): string;
190190
begin
191-
Result := THTML.CompoundTag('td', ImageTag(CompRes));
191+
Result := TXHTML.CompoundTag('td', ImageTag(CompRes));
192192
end;
193193

194194
class function TCompResHTML.TableRows(const CompileResults: TCompileResults):

Src/UDetailPageHTML.pas

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,10 @@ function TNulPageHTML.Generate: string;
391391

392392
function TNewTabPageHTML.GetBodyHTML: string;
393393
begin
394-
Result := THTML.CompoundTag(
394+
Result := TXHTML.CompoundTag(
395395
'div',
396396
THTMLAttributes.Create('id', 'newtab'),
397-
THTML.Entities(View.Description)
397+
TXHTML.Entities(View.Description)
398398
);
399399
end;
400400

@@ -452,9 +452,9 @@ procedure TWelcomePageHTML.ResolvePlaceholders(const Tplt: THTMLTemplate);
452452
for Compiler in Compilers do
453453
if Compiler.IsAvailable then
454454
CompilerList.AppendLine(
455-
THTML.CompoundTag(
455+
TXHTML.CompoundTag(
456456
'li',
457-
THTML.Entities(Compiler.GetName)
457+
TXHTML.Entities(Compiler.GetName)
458458
)
459459
);
460460
Tplt.ResolvePlaceholderHTML('CompilerList', CompilerList.ToString);
@@ -470,9 +470,9 @@ function TDBUpdatedPageHTML.GetBodyHTML: string;
470470
sBody = 'The database has been updated successfully.';
471471
begin
472472
Result :=
473-
THTML.CompoundTag('h1', View.Description)
473+
TXHTML.CompoundTag('h1', View.Description)
474474
+
475-
THTML.CompoundTag('p', sBody);
475+
TXHTML.CompoundTag('p', sBody);
476476
end;
477477

478478
{ TSnippetInfoPageHTML }
@@ -623,14 +623,14 @@ function TSnippetListPageHTML.SnippetTableRow(const Snippet: TSnippet): string;
623623
DescCellAttrs := THTMLAttributes.Create('class', 'desc');
624624
SnippetHTML := TSnippetHTML.Create(Snippet);
625625
try
626-
Result := THTML.CompoundTag(
626+
Result := TXHTML.CompoundTag(
627627
'tr',
628-
THTML.CompoundTag(
628+
TXHTML.CompoundTag(
629629
'td',
630630
NameCellAttrs,
631631
SnippetHTML.SnippetALink
632632
)
633-
+ THTML.CompoundTag('td', DescCellAttrs, SnippetHTML.Description)
633+
+ TXHTML.CompoundTag('td', DescCellAttrs, SnippetHTML.Description)
634634
);
635635
finally
636636
SnippetHTML.Free;

Src/UHTMLBuilder.pas

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,22 @@ implementation
142142

143143
procedure THTMLBuilder.AddText(const Text: string);
144144
begin
145-
fBodyInner.Append(THTML.Entities(Text));
145+
fBodyInner.Append(TXHTML.Entities(Text));
146146
end;
147147

148148
function THTMLBuilder.BodyTag: string;
149149
begin
150-
Result := THTML.CompoundTag(cBodyTag, EOL + HTMLFragment + EOL);
150+
Result := TXHTML.CompoundTag(cBodyTag, EOL + HTMLFragment + EOL);
151151
end;
152152

153153
procedure THTMLBuilder.ClosePre;
154154
begin
155-
fBodyInner.Append(THTML.ClosingTag(cPreTag));
155+
fBodyInner.Append(TXHTML.ClosingTag(cPreTag));
156156
end;
157157

158158
procedure THTMLBuilder.CloseSpan;
159159
begin
160-
fBodyInner.Append(THTML.ClosingTag(cSpanTag));
160+
fBodyInner.Append(TXHTML.ClosingTag(cSpanTag));
161161
end;
162162

163163
constructor THTMLBuilder.Create;
@@ -182,10 +182,10 @@ function THTMLBuilder.GetTitle: string;
182182

183183
function THTMLBuilder.HeadTag: string;
184184
begin
185-
Result := THTML.CompoundTag(
185+
Result := TXHTML.CompoundTag(
186186
cHeadTag,
187187
EOL
188-
+ THTML.CompoundTag(cTitleTag, THTML.Entities(Title))
188+
+ TXHTML.CompoundTag(cTitleTag, TXHTML.Entities(Title))
189189
+ EOL
190190
+ InlineStyleSheet
191191
);
@@ -222,7 +222,7 @@ function THTMLBuilder.HTMLTag: string;
222222
// ---------------------------------------------------------------------------
223223

224224
begin
225-
Result := THTML.CompoundTag(
225+
Result := TXHTML.CompoundTag(
226226
cHTMLTag,
227227
HTMLAttrs,
228228
EOL + HeadTag + EOL + BodyTag + EOL
@@ -237,7 +237,7 @@ function THTMLBuilder.InlineStyleSheet: string;
237237
begin
238238
Attrs := THTMLAttributes.Create('type', 'text/css');
239239
Result := EOL
240-
+ THTML.CompoundTag(cStyleTag, Attrs, EOL + fCSS + EOL)
240+
+ TXHTML.CompoundTag(cStyleTag, Attrs, EOL + fCSS + EOL)
241241
+ EOL;
242242
end
243243
else
@@ -258,12 +258,12 @@ procedure THTMLBuilder.NewLine;
258258

259259
procedure THTMLBuilder.OpenPre(const ClassName: string);
260260
begin
261-
fBodyInner.Append(THTML.OpeningTag(cPreTag, MakeClassAttr(ClassName)));
261+
fBodyInner.Append(TXHTML.OpeningTag(cPreTag, MakeClassAttr(ClassName)));
262262
end;
263263

264264
procedure THTMLBuilder.OpenSpan(const ClassName: string);
265265
begin
266-
fBodyInner.Append(THTML.OpeningTag(cSpanTag, MakeClassAttr(ClassName)));
266+
fBodyInner.Append(TXHTML.OpeningTag(cSpanTag, MakeClassAttr(ClassName)));
267267
end;
268268

269269
end.

Src/UHTMLTemplate.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ procedure THTMLTemplate.ResolvePlaceholderText(const Placeholder, Text: string);
105105
@param Text [in] Plain text to replace placeholder.
106106
}
107107
begin
108-
ResolvePlaceholderHTML(Placeholder, THTML.Entities(Text));
108+
ResolvePlaceholderHTML(Placeholder, TXHTML.Entities(Text));
109109
end;
110110

111111
end.

0 commit comments

Comments
 (0)