📄 sttohtml.pas
字号:
(* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is TurboPower SysTools
*
* The Initial Developer of the Original Code is
* TurboPower Software
*
* Portions created by the Initial Developer are Copyright (C) 1996-2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* ***** END LICENSE BLOCK ***** *)
{*********************************************************}
{* SysTools: StToHTML.pas 4.03 *}
{*********************************************************}
{* SysTools: HTML Text Formatter *}
{*********************************************************}
{$I StDefine.inc}
unit StToHTML;
interface
uses
SysUtils, Windows,
Messages, Classes, Graphics, Controls,
Forms, Dialogs, StStrms, StBase;
type
TStOnProgressEvent = procedure(Sender : TObject; Percent : Word) of object;
TStStreamToHTML = class(TObject)
protected {private}
{ Private declarations }
FCaseSensitive : Boolean;
FCommentMarkers : TStringList;
FEmbeddedHTML : TStringList;
FInFileSize : Cardinal;
FInFixedLineLen : integer;
FInLineTermChar : AnsiChar;
FInLineTerminator: TStLineTerminator;
FInputStream : TStream;
FInSize : Cardinal;
FInTextStream : TStAnsiTextStream;
FIsCaseSensitive : Boolean;
FKeywords : TStringList;
FOnProgress : TStOnProgressEvent;
FOutputStream : TStream;
FOutTextStream : TStAnsiTextStream;
FPageFooter : TStringList;
FPageHeader : TStringList;
FStringMarkers : TStringList;
FWordDelims : AnsiString;
protected
{ Protected declarations }
{internal methods}
function ParseBuffer : Boolean;
procedure SetCommentMarkers(Value : TStringList);
procedure SetEmbeddedHTML(Value : TStringList);
procedure SetKeywords(Value : TStringList);
procedure SetPageFooter(Value : TStringList);
procedure SetPageHeader(Value : TStringList);
procedure SetStringMarkers(Value : TStringList);
public
{ Public declarations }
property CaseSensitive : Boolean
read FCaseSensitive
write FCaseSensitive;
property CommentMarkers : TStringList
read FCommentMarkers
write SetCommentMarkers;
property EmbeddedHTML : TStringList
read FEmbeddedHTML
write SetEmbeddedHTML;
property InFixedLineLength : integer
read FInFixedLineLen
write FInFixedLineLen;
property InLineTermChar : AnsiChar
read FInLineTermChar
write FInLineTermChar;
property InLineTerminator : TStLineTerminator
read FInLineTerminator
write FInLineTerminator;
property InputStream : TStream
read FInputStream
write FInputStream;
property Keywords : TStringList
read FKeywords
write SetKeywords;
property OnProgress : TStOnProgressEvent
read FOnProgress
write FOnProgress;
property OutputStream : TStream
read FOutputStream
write FOutputStream;
property PageFooter : TStringList
read FPageFooter
write SetPageFooter;
property PageHeader : TStringList
read FPageHeader
write SetPageHeader;
property StringMarkers : TStringList
read FStringMarkers
write SetStringMarkers;
property WordDelimiters : AnsiString
read FWordDelims
write FWordDelims;
constructor Create;
destructor Destroy; override;
procedure GenerateHTML;
end;
TStFileToHTML = class(TStComponent)
protected {private}
{ Private declarations }
FCaseSensitive : Boolean;
FCommentMarkers : TStringList;
FEmbeddedHTML : TStringList;
FInFile : TFileStream;
FInFileName : AnsiString;
FInLineLength : integer;
FInLineTermChar : AnsiChar;
FInLineTerminator : TStLineTerminator;
FKeywords : TStringList;
FOnProgress : TStOnProgressEvent;
FOutFile : TFileStream;
FOutFileName : AnsiString;
FPageFooter : TStringList;
FPageHeader : TStringList;
FStream : TStStreamToHTML;
FStringMarkers : TStringList;
FWordDelims : AnsiString;
protected
procedure SetCommentMarkers(Value : TStringList);
procedure SetEmbeddedHTML(Value : TStringList);
procedure SetKeywords(Value : TStringList);
procedure SetPageFooter(Value : TStringList);
procedure SetPageHeader(Value : TStringList);
procedure SetStringMarkers(Value : TStringList);
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
procedure Execute;
published
property CaseSensitive : Boolean
read FCaseSensitive
write FCaseSensitive default False;
property CommentMarkers : TStringList
read FCommentMarkers
write SetCommentMarkers;
property EmbeddedHTML : TStringList
read FEmbeddedHTML
write SetEmbeddedHTML;
property InFileName : AnsiString
read FInFileName
write FInFileName;
property InFixedLineLength : integer
read FInLineLength
write FInLineLength default 80;
property InLineTermChar : AnsiChar
read FInLineTermChar
write FInLineTermChar default #10;
property InLineTerminator : TStLineTerminator
read FInLineTerminator
write FInLineTerminator default ltCRLF;
property Keywords : TStringList
read FKeywords
write SetKeywords;
property OnProgress : TStOnProgressEvent
read FOnProgress
write FOnProgress;
property OutFileName : AnsiString
read FOutFileName
write FOutFileName;
property PageFooter : TStringList
read FPageFooter
write SetPageFooter;
property PageHeader : TStringList
read FPageHeader
write SetPageHeader;
property StringMarkers : TStringList
read FStringMarkers
write SetStringMarkers;
property WordDelimiters : AnsiString
read FWordDelims
write FWordDelims;
end;
implementation
uses
StConst,
StDict;
(*****************************************************************************)
(* TStStreamToHTML Implementation *)
(*****************************************************************************)
constructor TStStreamToHTML.Create;
begin
inherited Create;
FCommentMarkers := TStringList.Create;
FEmbeddedHTML := TStringList.Create;
FKeywords := TStringList.Create;
FPageFooter := TStringList.Create;
FPageHeader := TStringList.Create;
FStringMarkers := TStringList.Create;
FInputStream := nil;
FOutputStream := nil;
FInFileSize := 0;
FWordDelims := ',; .()';
FInLineTerminator := ltCRLF; {normal Windows text file terminator}
FInLineTermChar := #10;
FInFixedLineLen := 80;
with FEmbeddedHTML do begin
Add('"="');
Add('&=&');
Add('<=<');
Add('>=>');
Add('
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -