wiki: internal links with anchors

git-svn-id: trunk@35892 -
This commit is contained in:
mattias 2012-03-11 16:20:45 +00:00
parent 1ae66cb238
commit cc9350c2d2
3 changed files with 15 additions and 2 deletions

View File

@ -214,6 +214,8 @@ var
Node: TDOMElement;
TargetPage: TW2XHTMLPage;
FoundImgFile: String;
DocumentName: String;
Anchor: String;
begin
Result:=false;
if LinkToken.Token=wptExternLink then exit;
@ -277,10 +279,20 @@ var
// default: a page
if URL<>'' then begin
Filename:=PageToFilename(URL,true,false);
p:=Pos('#',URL);
if p<1 then begin
DocumentName:=URL;
Anchor:='';
end else begin
DocumentName:=LeftStr(URL,p-1);
Anchor:=copy(URL,p+1,length(URL));
end;
Filename:=PageToFilename(DocumentName,true,false);
TargetPage:=TW2XHTMLPage(ShortFilenameToPage[Filename]);
if (TargetPage<>nil) then begin
URL:=GetPageLink(TargetPage);
if Anchor<>'' then
URL+='#'+Anchor;
end else if (not FileExistsUTF8(Filename)) then begin
if WarnMissingPageLinks and WarnURL(LinkToken.Link) then
Log('WARNING: TWiki2XHTMLConverter.InsertLink "'+dbgstr(LinkToken.Link)+'": file not found: "'+Filename+'" at '+W.PosToStr(LinkToken.LinkStartPos,true));

View File

@ -1536,7 +1536,7 @@ begin
case Result[i] of
' ',#9:
Result[i]:='_';
#0..#8,#10..#31,'#','$','[',']','{','}','<','>':
#0..#8,#10..#31,'$','[',']','{','}','<','>':
Delete(Result,i,1);
'%':
begin

View File

@ -290,6 +290,7 @@ begin
WikiHelp.ImagesDirectory:=SetDirSeparators('../images');
WikiHelp.Converter.OutputDir:='';
WikiHelp.Converter.CSSFilename:='wiki.css';
WikiHelp.Converter.WarnMissingPageLinks:=true;
WikiHelp.OnScanned:=@WikiHelpScanned;
WikiHelp.OnSearched:=@WikiHelpSearched;
WikiHelp.ResultsCSSURL:='wiki.css';