Share

Delphi Dom HTML Parser and Converter

Tracker: Patches

5 Add function to keep commented scripts in proper hierarchy. - ID: 922199
Last Update: Tracker Item Submitted ( nobody )

IN FILE formatter.pas

1. Modify uses

uses
DomCore, Classes;
(Not required if you can do this better without
TStringList).


2. Add new function after TrimLeftSpaces. // I use tabs,
so this must be modified to use (FIndent * FDepth).
---------------------------
function IndentText(S: TDomString; Depth: Integer):
TDomString;
var
Str: string;
TmpStr: TStringList;
I, J: Integer;
begin
TmpStr := TStringList.Create;
try
TmpStr.Text := S;
for I := 1 to TmpStr.Count - 1 do
// Start at 1, don't indent first line with <!--
begin
Str := TrimLeftSpaces
(TmpStr[I]);
SetLength(Str, Length(Str)
+ Depth);
for J := Length(Str) downto
Depth + 1 do
Str[J] := Str[J -
Depth];
for J := Depth downto 1 do
Str[J] := #9;
TmpStr[I] := Str;
end;
Result := TmpStr.Text;
SetLength(Result, Length(Result) -
2); // Remove trailing #D#A added by TStringList
finally
TmpStr.Free;
end;
end;
---------------------------
3. Modify class method

procedure TBaseFormatter.ProcessComment(Comment:
TComment);
begin
AppendText('<!--');
AppendText(IndentText(Comment.data,
FDepth)); // Call IndentText
AppendText('-->')
end;


Nobody/Anonymous ( nobody ) - 2004-03-24 04:56

5

Open

None

Nobody/Anonymous

None

None

Public


Comments




Log in to comment.

No follow-up comments have been posted.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.