Description | uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables |
Delphi/Kylix/FreePascal wrapper for TidyLib
The tidyobj unit provides a high-level, object-oriented wrapper around HTML-Tidy's TidyLib library.
The central component of this unit is the TTidy object, but the unit also imports the complete TidyLib API bindings, and provides additional features for traversing and querying a TidyDoc document tree.
Note to Lazarus users:
You should use the laztidy
unit for Lazarus projects, it offers identical functionality to tidyobj
, but provides some special $DEFINE's and intitialization needed for the Lazarus component.
To avoid duplication of effort, the core TidyLib bindings are not documented here, consult the TidyLib API documentation from the HTML-Tidy website for this information.
Name | Description |
---|---|
Class TTidy |
The main component of the TidyPas wrapper. |
Class tNodeInfo |
Dynamic structure used to pass information to a ForEachNode callback. |
Class tTidyBus |
Class to facilitate minor editing operations on a TidyDoc. |
procedure ForEachAttr(const info:tNodeInfo;callback:tAttrCallback;data:pointer); |
procedure ForEachNode(doc:pTidyDoc;start:pTidyNode;callback:tNodeCallback;data:pointer); |
procedure ForEachTag(doc:pTidyDoc;start:pTidyNode;tag:TidyTagID;cb:tNodeCallback;data:pointer); |
procedure ForEachTagInTags(doc:pTidyDoc;start:pTidyNode;tags:tTidyTagSet;cb:tNodeCallback;data:pointer); |
function TagNameToTagID(name:pChar):TidyTagID; |
function AttrNameToAttrID(name:pChar):TidyAttrID; |
function FindAncestor(anode:pTidyNode;tag:TidyTagID;attr:TidyAttrID):pTidyNode; |
procedure tidyBufLineEnd(buf:pTidyBuffer;eol:TidyLineEnding); |
procedure EntsToChars(src:pChar); overload; |
procedure EntsToChars(var src:ansistring); overload; |
function RowColToOffset(src:pChar;row,col:Cardinal;LineBreak:pChar):pChar; |
function FindTag(haystack:pChar;needle:pChar):pChar; |
procedure ForEachTagStr(src:pChar;cb:tForEachTagStrCallback;user_data:pointer); |
function FormatTidyReportMessage(level:TidyReportLevel;line:uint;col:uint;msg:ctmbstr):ansistring; |
tTidyTagSet=set of TidyTagID; |
tEndTagRule = (...); |
tAttrCallback = procedure(const info:tNodeInfo;name:pChar;value:pChar;user_data:pointer); |
tNodeCallback = procedure(const info:tNodeInfo;user_data:pointer); |
tTagNameStr=array[0..17] of char; |
tTidyBusInsertMode = (...); |
tTidyBusCopyMode = (...); |
TidyEncodingID = (...); |
tTidyInputCompleteEvent = procedure(sender:TObject;buf:Pchar;len:Cardinal)of object; |
tTidyInputCompleteCallback = procedure(sender:TObject;buf:pTidyBuffer); |
tTidyReportEvent = procedure(sender:TObject;level:TidyReportLevel;line, col:Cardinal;msg:String)of object; |
tForEachTagStrCallback = procedure(tag:pChar;var proceed:boolean;user_data:pointer); |
ElementsWithoutEndTags: set of TidyTagID = [...]; |
ElementsWithOptionalEndTags: set of TidyTagID = [...]; |
TypesWithoutEndTags: set of TidyNodeType = [...]; |
BlockLevelTags: set of TidyTagID = [...]; |
TAG_BUF_SIZE=256; |
TagNames:array[TidyTag_A..TidyTag_XMP] of tTagNameStr=(); |
AttrNames:array[TidyAttr_ABBR..TidyAttr_URN] of tTagNameStr=(); |
TIDY_NULL_FILE='/dev/null'; |
procedure ForEachAttr(const info:tNodeInfo;callback:tAttrCallback;data:pointer); |
ForEachAttr() will call your tAttrCallback once for each attribute of the node specified in the given tNodeInfo. The data parameter is an arbitrary pointer that will be passed to the callback as the user_data argument. |
procedure ForEachNode(doc:pTidyDoc;start:pTidyNode;callback:tNodeCallback;data:pointer); |
ForEachNode() will iterate through the Your tNodeCallback will be called once for each node at the same level as start, setting the fields of the tNodeInfo object to reflect the current TidyNode. To recurse into the child nodes of a node, you must call ForEachNode() again from within your callback, e.g. procedure MyNodeCallback(const info:tNodeInfo; user_data:pointer); begin ForEachNode(info.doc, info.child, @MyNodeCallback, user_data); end; Setting |
procedure ForEachTag(doc:pTidyDoc;start:pTidyNode;tag:TidyTagID;cb:tNodeCallback;data:pointer); |
ForEachTag() will traverse ALL elements of the document (including children), starting at the specified pTidyNode. Your callback will be called once for each node that matches the specified TAG. If the TAG argument is set to |
procedure ForEachTagInTags(doc:pTidyDoc;start:pTidyNode;tags:tTidyTagSet;cb:tNodeCallback;data:pointer); |
ForEachTagInTags() is basically the same as the ForEachTag() procedure, except that the callback is called for any node whose tag is a member of the |
function TagNameToTagID(name:pChar):TidyTagID; |
Convert a tag name to a TidyTagID, returns TidyTag_UNKNOWN if the string is not a default HTML-4 tag name. Note that the match is NOT case-sensitive. |
procedure tidyBufLineEnd(buf:pTidyBuffer;eol:TidyLineEnding); |
Appends the specified EOL to the buffer, specify one of: TidyLF for unix, TidyCRLF for ms-dos/windows, or TidyCR for macintosh. |
procedure EntsToChars(var src:ansistring); overload; |
Same as the EntsToChars(src:pChar) procedure, overloaded to use AnsiString instead of pChar. |
procedure ForEachTagStr(src:pChar;cb:tForEachTagStrCallback;user_data:pointer); |
ForEachTagStr will call your tForEachTagStrCallback once for each markup tag it finds in source. Note that this procedure is implemented by TidyPas, not by the TidyLib library. |
tTidyTagSet=set of TidyTagID; |
Set type used to describe an arbitrary group of TidyTagID's |
tAttrCallback = procedure(const info:tNodeInfo;name:pChar;value:pChar;user_data:pointer); |
Procedural type used as a callback by the ForEachAttr() procedure |
tNodeCallback = procedure(const info:tNodeInfo;user_data:pointer); |
Procedural type used as a callback by the ForEachNode() procedure |
tTagNameStr=array[0..17] of char; |
Internal type, used to define constants for element and attribute names. |
tTidyInputCompleteEvent = procedure(sender:TObject;buf:Pchar;len:Cardinal)of object; |
Procedural type used by TTidy's OnInputComplete event. |
tTidyInputCompleteCallback = procedure(sender:TObject;buf:pTidyBuffer); |
Procedural type used by TTidy's InputComplete callback. |
tTidyReportEvent = procedure(sender:TObject;level:TidyReportLevel;line, col:Cardinal;msg:String)of object; |
Procedural type used by TTidy's OnReport event. |
tForEachTagStrCallback = procedure(tag:pChar;var proceed:boolean;user_data:pointer); |
Procedural type used as a callback by the ForEachTagStr procedure. |
ElementsWithoutEndTags: set of TidyTagID = [...]; |
Elements that can never have a closing </tag> |
ElementsWithOptionalEndTags: set of TidyTagID = [...]; |
Elements that can optionally have a closing </tag> |
TypesWithoutEndTags: set of TidyNodeType = [...]; |
TidyNodeType's that can never have a closing </tag> |
TagNames:array[TidyTag_A..TidyTag_XMP] of tTagNameStr=(); |
Names of standard HTML-4 elements |
AttrNames:array[TidyAttr_ABBR..TidyAttr_URN] of tTagNameStr=(); |
Names of standard HTML-4 attributes |
TIDY_NULL_FILE='/dev/null'; |
Describes the system's "trash can" file, e.g. |
December 9, 2005
December 9, 2005