%
var
aTopicList: THndTopicsInfoArray;
sDefaultTopicId: string;
nCurTopic, nHeaderKind, nFooterKind: integer;
sTopicHeader, sTopicFooter: string;
sTocContent: string;
oEditor: TObject;
isNextDefaultTheIndex, isGeneratingIndex: Boolean;
// Generate the CSS for the whole project
procedure GenerateContentCss();
var
sCssContent: string;
begin
HndGeneratorInfo.CurrentFile := 'css\hnd.content.css';
sCssContent := HndProjects.GetProjectCssContent();
sCssContent := StringReplace(sCssContent, 'body, table,', '.main-content, .main-content table', [rfIgnoreCase]);
print(sCssContent);
end;
// Generate the search data
procedure GenerateSearchData();
begin
HndGeneratorInfo.CurrentFile := 'js\hndsd.min.js';
print(HndJsSearchEngine.GetJsData());
// Clear the search engine
HndJsSearchEngine.ClearSearchData();
end;
function GetCustomCss: string;
begin
Result := HndGeneratorInfo.GetCustomSettingValue('CustomCss');
if (Result <> '') then
Result := '';
end;
function GetCustomJs: string;
begin
Result := HndGeneratorInfo.GetCustomSettingValue('CustomJs');
if (Result <> '') then
Result := '';
end;
function GetHtmlParamValue(Value: string): string;
begin
// Replace double quotes
Result := StringReplace(Value, '"', '\"', [rfReplaceAll]);
end;
// Returns the footer
function GetTemplateHtmlFooter: string;
begin
Result := HndGeneratorInfo.GetCustomSettingValue('Footer');
end;
// Returns the icon
function GetIconAsHtml: string;
var
aLogoId: string;
aLogoContent: TMemoryStream;
begin
aLogoId := HndGeneratorInfo.GetCustomSettingValue('Logo');
if aLogoId <> '' then
begin
aLogoContent := HndLibraryItems.GetItemContent(aLogoId);
if Assigned(aLogoContent) then
try
if (aLogoContent.Size > 0) then
begin
// Save logo
aLogoContent.SaveToFile(ExtractFilePath(HndGeneratorInfo.OutputFile) + '_logo.png');
// Return HTML
Result := '';
end;
finally
aLogoContent.Free;
end;
end;
end;
// Returns the theme CSS
function GetThemeAsHtml: string;
var
aThemeName: string;
begin
aThemeName := LowerCase(HndGeneratorInfo.GetCustomSettingValue('Theme'));
Result := Format('', [aThemeName]);
end;
// Returns HTML/CSS to customize the width of the Toc
function GetTocWidthAsHtml: string;
var
aSize: integer;
begin
Result := '';
// Get value
aSize := StrToIntDef(HndGeneratorInfo.GetCustomSettingValue('TocWidth'), 0);
// Return content
if (aSize > 0) then
begin
Result := Format('', [aSize, aSize, aSize + 14]);
end;
end;
// Returns a list of keywords
function GetTopicKeywordsAsHtml: string;
var
aTopicKeywords: array of string;
nCurKeyword: integer;
begin
Result := '';
aTopicKeywords := HndTopicsKeywords.GetKeywordsAssociatedWithTopic(HndGeneratorInfo.CurrentTopic);
for nCurKeyword := 0 to High(aTopicKeywords) do
begin
if nCurKeyword > 0 then print(', ');
Result := Result + HTMLEncode(HndKeywords.GetKeywordCaption(aTopicKeywords[nCurKeyword]));
end;
end;
// Returns the formatted breadcrumb for the current topic
function GetTopicBreadCrumbAsHtml: string;
var
aBreadCrumb: array of string;
sRelativeTopic: string;
nCurParent: Integer;
begin
Result := '';
// Create the breadcrumb
SetLength(aBreadCrumb, 0);
if HndGeneratorInfo.GetCustomSettingValue('ShowBreadCrumbs') then
begin
sRelativeTopic := HndTopics.GetTopicParent(HndGeneratorInfo.CurrentTopic);
while (sRelativeTopic <> '') and (sRelativeTopic <> HndTopics.GetProjectTopic()) do
begin
SetLength(aBreadCrumb, Length(aBreadCrumb) + 1);
aBreadCrumb[Length(aBreadCrumb) - 1] := sRelativeTopic;
sRelativeTopic := HndTopics.GetTopicParent(sRelativeTopic);
end;
end;
// Return it if any
if (Length(aBreadCrumb) > 0) then
begin
for nCurParent := Length(aBreadCrumb) - 1 downto 0 do
begin
// Empty topic
if (HndTopics.GetTopicKind(aBreadCrumb[nCurParent]) = 1) then
begin
Result := Result + format('