mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 15:39:29 +02:00
* Added option to split lines
git-svn-id: trunk@32896 -
This commit is contained in:
parent
a87e83e9b7
commit
65976e4db3
@ -23,6 +23,7 @@ uses DOM, dGlobals, PasTree;
|
||||
|
||||
const
|
||||
LateXHighLight : Boolean = False;
|
||||
MaxVerbatimLength : Integer = 65;
|
||||
TexExtension : String = '.tex';
|
||||
|
||||
Procedure CreateLaTeXDocForPackage(APackage: TPasPackage; AEngine: TFPDocEngine);
|
||||
@ -130,6 +131,7 @@ Type
|
||||
// TFPDocWriter class methods
|
||||
Property ImageDir : String Read FImageDir Write FImageDir;
|
||||
public
|
||||
Function SplitLine (ALine : String): String; virtual;
|
||||
Function InterPretOption(Const Cmd,Arg : String) : boolean; override;
|
||||
Class Function FileNameExtension : String; override;
|
||||
end;
|
||||
@ -153,15 +155,75 @@ begin
|
||||
Result[i] := ':';
|
||||
end;
|
||||
|
||||
Function TLaTeXWriter.SplitLine (ALine : String): String;
|
||||
|
||||
Function FindLastSplit(S : String) : Integer;
|
||||
|
||||
Const
|
||||
NonSplit = ['a'..'z','A'..'Z','0'..'9','_'];
|
||||
|
||||
Var
|
||||
L,I : integer;
|
||||
C : PChar;
|
||||
InString : Boolean;
|
||||
|
||||
begin
|
||||
Result:=0;
|
||||
L:=Length(S);
|
||||
if (L>MaxVerbatimLength) then
|
||||
begin
|
||||
InString:=False;
|
||||
Result:=0;
|
||||
I:=1;
|
||||
C:=@S[1];
|
||||
While (I<=MaxVerbatimLength) do
|
||||
begin
|
||||
If C^='''' then
|
||||
InString:=Not Instring
|
||||
else if Not InString then
|
||||
begin
|
||||
if Not (C^ in NonSplit) then
|
||||
Result:=I;
|
||||
end;
|
||||
Inc(I);
|
||||
Inc(C);
|
||||
end;
|
||||
end;
|
||||
If Result=0 then
|
||||
Result:=L+1;
|
||||
end;
|
||||
|
||||
Var
|
||||
SP : Integer;
|
||||
L : String;
|
||||
|
||||
begin
|
||||
Result:='';
|
||||
While (Aline<>'') do
|
||||
begin
|
||||
SP:=FindLastSplit(Aline);
|
||||
L:=Copy(ALine,1,SP-1);
|
||||
Delete(ALine,1,SP-1);
|
||||
If (Result<>'') then
|
||||
Result:=Result+sLineBreak+' ';
|
||||
Result:=Result+Trim(L);
|
||||
end;
|
||||
end;
|
||||
|
||||
function TLaTeXWriter.EscapeText(S: String): String;
|
||||
|
||||
|
||||
var
|
||||
i: Integer;
|
||||
|
||||
begin
|
||||
if FInVerBatim=True then
|
||||
Result:=S
|
||||
begin
|
||||
if (MaxVerbatimLength=0) or (length(S)<=MaxVerbatimLength) then
|
||||
Result:=S
|
||||
else
|
||||
Result:=SplitLine(S);
|
||||
end
|
||||
else
|
||||
begin
|
||||
SetLength(Result, 0);
|
||||
@ -725,6 +787,8 @@ begin
|
||||
LatexHighLight:=True
|
||||
else if Cmd = '--latex-extension' then
|
||||
TexExtension:=Arg
|
||||
else if Cmd = '--latex--verbatim-length' then
|
||||
MaxVerbatimLength:=StrToInt(Arg)
|
||||
else if Cmd = '--image-dir' then
|
||||
ImageDir:=Arg
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user