* Added support for the url tag to include arbitrary links

git-svn-id: trunk@14167 -
This commit is contained in:
michael 2009-11-13 15:58:45 +00:00
parent f326302a12
commit 9fff5d989c
6 changed files with 64 additions and 4 deletions

View File

@ -154,6 +154,7 @@ resourcestring
SDone = 'Done.';
SErrCouldNotCreateOutputDir = 'Could not create output directory "%s"';
SErrCouldNotCreateFile = 'Could not create file "%s": %s';
SSeeURL = '(See %s)'; // For lineair text writers.
Const
SVisibility: array[TPasMemberVisibility] of string =

View File

@ -149,6 +149,8 @@ type
procedure DescrWriteVarEl(const AText: DOMString); override;
procedure DescrBeginLink(const AId: DOMString); override;
procedure DescrEndLink; override;
procedure DescrBeginURL(const AURL: DOMString); override;
procedure DescrEndURL; override;
procedure DescrWriteLinebreak; override;
procedure DescrBeginParagraph; override;
procedure DescrEndParagraph; override;
@ -1088,6 +1090,16 @@ begin
PopOutputNode;
end;
procedure THTMLWriter.DescrBeginURL(const AURL: DOMString);
begin
PushOutputNode(CreateLink(CurOutputNode, AURL));
end;
procedure THTMLWriter.DescrEndURL;
begin
PopOutputNode;
end;
procedure THTMLWriter.DescrWriteLinebreak;
begin
CreateEl(CurOutputNode, 'br');

View File

@ -92,6 +92,8 @@ Type
procedure DescrWriteVarEl(const AText: DOMString); override;
procedure DescrBeginLink(const AId: DOMString); override;
procedure DescrEndLink; override;
procedure DescrBeginURL(const AURL: DOMString); override; // Provides a default implementation
procedure DescrEndURL; override;
procedure DescrWriteLinebreak; override;
procedure DescrBeginParagraph; override;
procedure DescrBeginCode(HasBorder: Boolean; const AHighlighterName: String); override;
@ -273,6 +275,18 @@ begin
WriteF(' (\pageref{%s})',[StripText(Flink)]);
end;
procedure TLaTeXWriter.DescrBeginURL(const AURL: DOMString);
begin
Inherited; // Save link
Write('\htmladdnormallink{');
end;
procedure TLaTeXWriter.DescrEndURL;
begin
WriteF('}{%s}',[LastURL]);
LastURL:='';
end;
procedure TLaTeXWriter.DescrWriteLinebreak;
begin
WriteLn('\\');

View File

@ -15,8 +15,8 @@ Type
PackageName: String;
Module: TPasModule;
ModuleName: String;
FLastURL : DomString;
Protected
// Writing support.
procedure Write(const s: String); virtual;
procedure WriteLn(const s: String); virtual;
@ -27,6 +27,8 @@ Type
procedure WriteLabel(El: TPasElement);
procedure WriteIndex(El: TPasElement);
// Auxiliary routines
procedure DescrBeginURL(const AURL: DOMString); override; // Provides a default implementation
procedure DescrEndURL; override;
procedure SortElementList(List : TList);
procedure StartListing(Frames: Boolean);
Function ShowMember(M : TPasElement) : boolean;
@ -75,6 +77,7 @@ Type
procedure WriteUnitEntry(UnitRef : TPasType);virtual; Abstract;
procedure EndUnitOverview; virtual; Abstract;
Class Function FileNameExtension : String;virtual; Abstract;
Property LastURL : DomString Read FLastURL Write FLastURL;
Public
Constructor Create(APackage: TPasPackage; AEngine: TFPDocEngine); override;
procedure WriteDoc; override;
@ -196,6 +199,18 @@ begin
WriteIndex(EL.Name);
end;
procedure TLinearWriter.DescrBeginURL(const AURL: DOMString);
begin
FLastURL:=AURL;
end;
procedure TLinearWriter.DescrEndURL;
begin
If (FLastURL<>'') then
Writeln(Format(SSeeURL,[EscapeText(FLastURL)]));
FLastURL:='';
end;
procedure TLinearWriter.StartListing(Frames: Boolean);
begin
StartListing(Frames,'');

View File

@ -71,6 +71,7 @@ type
FPackage : TPasPackage;
FTopics : TList;
FImgExt : String;
procedure ConvertURL(AContext: TPasElement; El: TDOMElement);
protected
procedure Warning(AContext: TPasElement; const AMsg: String);
@ -111,6 +112,8 @@ type
procedure DescrWriteVarEl(const AText: DOMString); virtual; abstract;
procedure DescrBeginLink(const AId: DOMString); virtual; abstract;
procedure DescrEndLink; virtual; abstract;
procedure DescrBeginURL(const AURL: DOMString); virtual; abstract;
procedure DescrEndURL; virtual; abstract;
procedure DescrWriteLinebreak; virtual; abstract;
procedure DescrBeginParagraph; virtual; abstract;
procedure DescrEndParagraph; virtual; abstract;
@ -428,6 +431,7 @@ begin
if Node.NodeType = ELEMENT_NODE then
if (Node.NodeName <> 'br') and
(Node.NodeName <> 'link') and
(Node.NodeName <> 'url') and
(Node.NodeName <> 'b') and
(Node.NodeName <> 'file') and
(Node.NodeName <> 'i') and
@ -457,6 +461,8 @@ begin
begin
if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'link') then
ConvertLink(AContext, TDOMElement(Node))
else if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'url') then
ConvertURL(AContext, TDOMElement(Node))
else
if not ConvertBaseShort(AContext, Node) then
exit;
@ -596,6 +602,16 @@ begin
DescrEndLink;
end;
procedure TFPDocWriter.ConvertURL(AContext: TPasElement; El: TDOMElement);
begin
DescrBeginURL(El['href']);
if not IsDescrNodeEmpty(El) then
ConvertBaseShortList(AContext, El, True)
else
DescrWriteText(El['href']);
DescrEndURL;
end;
function TFPDocWriter.ConvertExtShort(AContext: TPasElement;
Node: TDOMNode): Boolean;
begin
@ -605,6 +621,8 @@ begin
begin
if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'link') then
ConvertLink(AContext, TDOMElement(Node))
else if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'url') then
ConvertURL(AContext, TDOMElement(Node))
else if (Node.NodeType = ELEMENT_NODE) and (Node.NodeName = 'br') then
DescrWriteLinebreak
else

View File

@ -1,18 +1,18 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="/"/>
<Version Value="6"/>
<Version Value="7"/>
<General>
<Flags>
<SaveClosedFiles Value="False"/>
<SaveOnlyProjectUnits Value="True"/>
<MainUnitHasUsesSectionForAllUnits Value="False"/>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<LRSInOutputDirectory Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=""/>
</General>
<VersionInfo>