mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-27 15:39:42 +02:00
added support for use of absolute links with content files
git-svn-id: trunk@2311 -
This commit is contained in:
parent
3207ce77e1
commit
8a02b500ed
@ -279,12 +279,16 @@ procedure TranslateDocStrings(const Lang: String);
|
||||
Function IsLinkNode(Node : TDomNode) : Boolean;
|
||||
Function IsExampleNode(Example : TDomNode) : Boolean;
|
||||
|
||||
|
||||
// returns true is link is an absolute URI
|
||||
Function IsLinkAbsolute(ALink: String): boolean;
|
||||
|
||||
implementation
|
||||
|
||||
uses SysUtils, Gettext, XMLRead;
|
||||
|
||||
const
|
||||
AbsoluteLinkPrefixes : array[0..2] of string = ('/', 'http://', 'ms-its:');
|
||||
|
||||
|
||||
{ TObjectList }
|
||||
|
||||
@ -697,6 +701,8 @@ var
|
||||
var
|
||||
s: String;
|
||||
begin
|
||||
if not FileExists(AFileName) then
|
||||
raise EInOutError.Create('File not found: ' + AFileName);
|
||||
Assign(f, AFilename);
|
||||
Reset(f);
|
||||
while not EOF(f) do
|
||||
@ -1216,6 +1222,18 @@ begin
|
||||
Result:=Assigned(Example) and (Example.NodeType = ELEMENT_NODE) and (Example.NodeName = 'example')
|
||||
end;
|
||||
|
||||
function IsLinkAbsolute(ALink: String): boolean;
|
||||
var
|
||||
i: integer;
|
||||
begin
|
||||
Result := false;
|
||||
for i := low(AbsoluteLinkPrefixes) to high(AbsoluteLinkPrefixes) do
|
||||
if CompareText(AbsoluteLinkPrefixes[i], copy(ALink,1,length(AbsoluteLinkPrefixes[i])))=0 then begin
|
||||
Result := true;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
|
||||
initialization
|
||||
LEOL:=Length(LineEnding);
|
||||
end.
|
||||
|
@ -768,7 +768,7 @@ begin
|
||||
if Length(Result) > 0 then
|
||||
if Copy(Result, 1, Length(CurDirectory) + 1) = CurDirectory + '/' then
|
||||
Result := Copy(Result, Length(CurDirectory) + 2, Length(Result))
|
||||
else
|
||||
else if not IsLinkAbsolute(Result) then
|
||||
Result := BaseDirectory + Result;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user