From a18212c351c03dcbd59c692be0b0b062ac9b7ed0 Mon Sep 17 00:00:00 2001 From: macpgmr Date: Tue, 11 Aug 2015 16:43:09 +0000 Subject: [PATCH] Create more meaningful HTML links from help. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@4264 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/xdev_toolkit/CvtHelp.pas | 43 ++++++++++++++++------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/components/xdev_toolkit/CvtHelp.pas b/components/xdev_toolkit/CvtHelp.pas index 0760d0f9e..47e2fdd82 100644 --- a/components/xdev_toolkit/CvtHelp.pas +++ b/components/xdev_toolkit/CvtHelp.pas @@ -27,7 +27,7 @@ uses const ProgramName = 'CvtHelp'; - ProgramVersion = '0.01'; + ProgramVersion = '0.03'; var OldFileName : string; @@ -210,9 +210,13 @@ begin WriteLn(NewFileVar, '-->'); end + {Important note: If you formatted your topics or popup text (what + you're linking to) with a different style name, change or add to + the next few lines (remove spaces from your style names).} else if (Pos('class=Topictitle', InStr) > 0) or - (Pos('class=Topic>', InStr) > 0) then {Found a topic?} - begin + (Pos('class=Topic>', InStr) > 0) or + (Pos('class=Popuptext> 0) then {Found a topic?} + begin {Note since PopupText may have >1 paragraph, look for actual topic} {Get footnote number _ftnXX} FnPos := Pos('#_', InStr) + 1; FnRef := ''; @@ -227,8 +231,10 @@ begin TopicMapped := False; if MapSection.Values[TopicStr] <> '' then begin - WriteLn(NewFileVar, ''); + WriteLn(NewFileVar, ''); + //Was previously outputting MapSection.Values[TopicStr], which is + // just the help numeric value - more meaningful to use topic name + // (meaning same as non-mapped topics). TopicMapped := True; end; if not TopicMapped then {No mapping in project file for topic?} @@ -237,21 +243,21 @@ begin end; end; {Save part of 1st topic line} - if Pos('class=Topictitle', InStr) > 0 then - Write(NewFileVar, Copy(InStr, 1, Pos('class=Topictitle>', InStr)+16)) - else - Write(NewFileVar, Copy(InStr, 1, Pos('class=Topic>', InStr)+11)); + Write(NewFileVar, Copy(InStr, 1, Pos('>', InStr))); BuildStr := InStr; repeat {Get rest of topic lines} ReadLn(OldFileVar, InStr); if InStr <> '' then BuildStr := BuildStr + ' ' + InStr; until InStr = ''; - TopicPos := Length(BuildStr); - repeat - Dec(TopicPos); - until (TopicPos = 0) or (BuildStr[TopicPos] = '>'); - WriteLn(NewFileVar, Copy(BuildStr, TopicPos+2, MaxInt)); + TopicPos := Pos('+', BuildStr); + if TopicPos = 0 then + TopicPos := Pos('$', BuildStr); + if TopicPos = 0 then + TopicPos := Pos('#', BuildStr); + Delete(BuildStr, 1, TopicPos); + TopicPos := Pos('', BuildStr) + 5; + WriteLn(NewFileVar, Copy(BuildStr, TopicPos, MaxInt)); end else if CompareText(InStr, '

') = 0 then {Found footnotes?} @@ -288,11 +294,10 @@ begin if (Pos(TopicStr, InStr) > LinkPos) and (Pos(TopicStr, InStr) < NextLinkPos) then begin - BuildStr := Copy(InStr, 1, LinkPos-1) + '', InStr); BuildStr := BuildStr + '">' + Copy(InStr, LinkPos+3, UnlinkPos-LinkPos-3) + '' +