~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

TidyLib
tidy/src/tags.h

Version: ~ [ 1.0 ] ~

  1 #ifndef __TAGS_H__
  2 #define __TAGS_H__
  3 
  4 /* tags.h -- recognize HTML tags
  5 
  6   (c) 1998-2005 (W3C) MIT, ERCIM, Keio University
  7   See tidy.h for the copyright notice.
  8 
  9   CVS Info :
 10 
 11     $Author: arnaud02 $ 
 12     $Date: 2005/08/17 16:59:58 $ 
 13     $Revision: 1.14 $ 
 14 
 15   The HTML tags are stored as 8 bit ASCII strings.
 16   Use lookupw() to find a tag given a wide char string.
 17 
 18 */
 19 
 20 #include "forward.h"
 21 #include "attrdict.h"
 22 
 23 typedef void (Parser)( TidyDocImpl* doc, Node *node, uint mode );
 24 typedef void (CheckAttribs)( TidyDocImpl* doc, Node *node );
 25 
 26 /*
 27  Tag dictionary node
 28 */
 29 
 30 /* types of tags that the user can define */
 31 typedef enum
 32 {
 33     tagtype_null = 0,
 34     tagtype_empty = 1,
 35     tagtype_inline = 2,
 36     tagtype_block = 4,
 37     tagtype_pre = 8
 38 } UserTagType;
 39 
 40 struct _Dict
 41 {
 42     TidyTagId       id;
 43     tmbstr          name;
 44     uint            versions;
 45     AttrVersion const *    attrvers;
 46     uint            model;
 47     Parser*         parser;
 48     CheckAttribs*   chkattrs;
 49     Dict*           next;
 50 };
 51 
 52 #ifdef ELEMENT_HASH_LOOKUP
 53 #define ELEMENT_HASH_SIZE 178
 54 #endif
 55 
 56 struct _TidyTagImpl
 57 {
 58     Dict* xml_tags;                /* placeholder for all xml tags */
 59     Dict* declared_tag_list;       /* User declared tags */
 60 #ifdef ELEMENT_HASH_LOOKUP
 61     Dict* hashtab[ELEMENT_HASH_SIZE];
 62 #endif
 63 };
 64 
 65 typedef struct _TidyTagImpl TidyTagImpl;
 66 
 67 /* interface for finding tag by name */
 68 const Dict* LookupTagDef( TidyTagId tid );
 69 Bool    FindTag( TidyDocImpl* doc, Node *node );
 70 Parser* FindParser( TidyDocImpl* doc, Node *node );
 71 void    DefineTag( TidyDocImpl* doc, UserTagType tagType, ctmbstr name );
 72 void    FreeDeclaredTags( TidyDocImpl* doc, UserTagType tagType ); /* tagtype_null to free all */
 73 
 74 TidyIterator   GetDeclaredTagList( TidyDocImpl* doc );
 75 Dict*          GetNextDeclaredDict( TidyDocImpl* doc, TidyIterator* iter );
 76 ctmbstr        GetNextDeclaredTag( TidyDocImpl* doc, UserTagType tagType,
 77                                    TidyIterator* iter );
 78 
 79 void InitTags( TidyDocImpl* doc );
 80 void FreeTags( TidyDocImpl* doc );
 81 
 82 
 83 /* Parser methods for tags */
 84 
 85 Parser ParseHTML;
 86 Parser ParseHead;
 87 Parser ParseTitle;
 88 Parser ParseScript;
 89 Parser ParseFrameSet;
 90 Parser ParseNoFrames;
 91 Parser ParseBody;
 92 Parser ParsePre;
 93 Parser ParseList;
 94 Parser ParseLI;
 95 Parser ParseDefList;
 96 Parser ParseBlock;
 97 Parser ParseInline;
 98 Parser ParseEmpty;
 99 Parser ParseTableTag;
100 Parser ParseColGroup;
101 Parser ParseRowGroup;
102 Parser ParseRow;
103 Parser ParseSelect;
104 Parser ParseOptGroup;
105 Parser ParseText;
106 Parser ParseObject;
107 Parser ParseMap;
108 
109 /* Attribute checking methods */
110 
111 CheckAttribs CheckAttributes;
112 CheckAttribs CheckIMG;
113 CheckAttribs CheckLINK;
114 CheckAttribs CheckAREA;
115 CheckAttribs CheckTABLE;
116 CheckAttribs CheckCaption;
117 CheckAttribs CheckSCRIPT;
118 CheckAttribs CheckSTYLE;
119 CheckAttribs CheckHTML;
120 CheckAttribs CheckFORM;
121 CheckAttribs CheckMETA;
122 
123 /* 0 == TidyTag_UNKNOWN */
124 #define TagId(node)        ((node) && (node)->tag ? (node)->tag->id : TidyTag_UNKNOWN)
125 #define TagIsId(node, tid) ((node) && (node)->tag && (node)->tag->id == tid)
126 
127 Bool nodeIsText( Node* node );
128 Bool nodeIsElement( Node* node );
129 
130 Bool nodeHasText( TidyDocImpl* doc, Node* node );
131 
132 /* Compare & result to operand.  If equal, then all bits
133 ** requested are set.
134 */
135 Bool nodeMatchCM( Node* node, uint contentModel );
136 
137 /* True if any of the bits requested are set.
138 */
139 Bool nodeHasCM( Node* node, uint contentModel );
140 
141 Bool nodeCMIsBlock( Node* node );
142 Bool nodeCMIsInline( Node* node );
143 Bool nodeCMIsEmpty( Node* node );
144 
145 
146 Bool nodeIsHeader( Node* node );     /* H1, H2, ..., H6 */
147 uint nodeHeaderLevel( Node* node );  /* 1, 2, ..., 6 */
148 
149 #define nodeIsHTML( node )       TagIsId( node, TidyTag_HTML )
150 #define nodeIsHEAD( node )       TagIsId( node, TidyTag_HEAD )
151 #define nodeIsTITLE( node )      TagIsId( node, TidyTag_TITLE )
152 #define nodeIsBASE( node )       TagIsId( node, TidyTag_BASE )
153 #define nodeIsMETA( node )       TagIsId( node, TidyTag_META )
154 #define nodeIsBODY( node )       TagIsId( node, TidyTag_BODY )
155 #define nodeIsFRAMESET( node )   TagIsId( node, TidyTag_FRAMESET )
156 #define nodeIsFRAME( node )      TagIsId( node, TidyTag_FRAME )
157 #define nodeIsIFRAME( node )     TagIsId( node, TidyTag_IFRAME )
158 #define nodeIsNOFRAMES( node )   TagIsId( node, TidyTag_NOFRAMES )
159 #define nodeIsHR( node )         TagIsId( node, TidyTag_HR )
160 #define nodeIsH1( node )         TagIsId( node, TidyTag_H1 )
161 #define nodeIsH2( node )         TagIsId( node, TidyTag_H2 )
162 #define nodeIsPRE( node )        TagIsId( node, TidyTag_PRE )
163 #define nodeIsLISTING( node )    TagIsId( node, TidyTag_LISTING )
164 #define nodeIsP( node )          TagIsId( node, TidyTag_P )
165 #define nodeIsUL( node )         TagIsId( node, TidyTag_UL )
166 #define nodeIsOL( node )         TagIsId( node, TidyTag_OL )
167 #define nodeIsDL( node )         TagIsId( node, TidyTag_DL )
168 #define nodeIsDIR( node )        TagIsId( node, TidyTag_DIR )
169 #define nodeIsLI( node )         TagIsId( node, TidyTag_LI )
170 #define nodeIsDT( node )         TagIsId( node, TidyTag_DT )
171 #define nodeIsDD( node )         TagIsId( node, TidyTag_DD )
172 #define nodeIsTABLE( node )      TagIsId( node, TidyTag_TABLE )
173 #define nodeIsCAPTION( node )    TagIsId( node, TidyTag_CAPTION )
174 #define nodeIsTD( node )         TagIsId( node, TidyTag_TD )
175 #define nodeIsTH( node )         TagIsId( node, TidyTag_TH )
176 #define nodeIsTR( node )         TagIsId( node, TidyTag_TR )
177 #define nodeIsCOL( node )        TagIsId( node, TidyTag_COL )
178 #define nodeIsCOLGROUP( node )   TagIsId( node, TidyTag_COLGROUP )
179 #define nodeIsBR( node )         TagIsId( node, TidyTag_BR )
180 #define nodeIsA( node )          TagIsId( node, TidyTag_A )
181 #define nodeIsLINK( node )       TagIsId( node, TidyTag_LINK )
182 #define nodeIsB( node )          TagIsId( node, TidyTag_B )
183 #define nodeIsI( node )          TagIsId( node, TidyTag_I )
184 #define nodeIsSTRONG( node )     TagIsId( node, TidyTag_STRONG )
185 #define nodeIsEM( node )         TagIsId( node, TidyTag_EM )
186 #define nodeIsBIG( node )        TagIsId( node, TidyTag_BIG )
187 #define nodeIsSMALL( node )      TagIsId( node, TidyTag_SMALL )
188 #define nodeIsPARAM( node )      TagIsId( node, TidyTag_PARAM )
189 #define nodeIsOPTION( node )     TagIsId( node, TidyTag_OPTION )
190 #define nodeIsOPTGROUP( node )   TagIsId( node, TidyTag_OPTGROUP )
191 #define nodeIsIMG( node )        TagIsId( node, TidyTag_IMG )
192 #define nodeIsMAP( node )        TagIsId( node, TidyTag_MAP )
193 #define nodeIsAREA( node )       TagIsId( node, TidyTag_AREA )
194 #define nodeIsNOBR( node )       TagIsId( node, TidyTag_NOBR )
195 #define nodeIsWBR( node )        TagIsId( node, TidyTag_WBR )
196 #define nodeIsFONT( node )       TagIsId( node, TidyTag_FONT )
197 #define nodeIsLAYER( node )      TagIsId( node, TidyTag_LAYER )
198 #define nodeIsSPACER( node )     TagIsId( node, TidyTag_SPACER )
199 #define nodeIsCENTER( node )     TagIsId( node, TidyTag_CENTER )
200 #define nodeIsSTYLE( node )      TagIsId( node, TidyTag_STYLE )
201 #define nodeIsSCRIPT( node )     TagIsId( node, TidyTag_SCRIPT )
202 #define nodeIsNOSCRIPT( node )   TagIsId( node, TidyTag_NOSCRIPT )
203 #define nodeIsFORM( node )       TagIsId( node, TidyTag_FORM )
204 #define nodeIsTEXTAREA( node )   TagIsId( node, TidyTag_TEXTAREA )
205 #define nodeIsBLOCKQUOTE( node ) TagIsId( node, TidyTag_BLOCKQUOTE )
206 #define nodeIsAPPLET( node )     TagIsId( node, TidyTag_APPLET )
207 #define nodeIsOBJECT( node )     TagIsId( node, TidyTag_OBJECT )
208 #define nodeIsDIV( node )        TagIsId( node, TidyTag_DIV )
209 #define nodeIsSPAN( node )       TagIsId( node, TidyTag_SPAN )
210 #define nodeIsINPUT( node )      TagIsId( node, TidyTag_INPUT )
211 #define nodeIsQ( node )          TagIsId( node, TidyTag_Q )
212 #define nodeIsLABEL( node )      TagIsId( node, TidyTag_LABEL )
213 #define nodeIsH3( node )         TagIsId( node, TidyTag_H3 )
214 #define nodeIsH4( node )         TagIsId( node, TidyTag_H4 )
215 #define nodeIsH5( node )         TagIsId( node, TidyTag_H5 )
216 #define nodeIsH6( node )         TagIsId( node, TidyTag_H6 )
217 #define nodeIsADDRESS( node )    TagIsId( node, TidyTag_ADDRESS )
218 #define nodeIsXMP( node )        TagIsId( node, TidyTag_XMP )
219 #define nodeIsSELECT( node )     TagIsId( node, TidyTag_SELECT )
220 #define nodeIsBLINK( node )      TagIsId( node, TidyTag_BLINK )
221 #define nodeIsMARQUEE( node )    TagIsId( node, TidyTag_MARQUEE )
222 #define nodeIsEMBED( node )      TagIsId( node, TidyTag_EMBED )
223 #define nodeIsBASEFONT( node )   TagIsId( node, TidyTag_BASEFONT )
224 #define nodeIsISINDEX( node )    TagIsId( node, TidyTag_ISINDEX )
225 #define nodeIsS( node )          TagIsId( node, TidyTag_S )
226 #define nodeIsSTRIKE( node )     TagIsId( node, TidyTag_STRIKE )
227 #define nodeIsSUB( node )        TagIsId( node, TidyTag_SUB )
228 #define nodeIsSUP( node )        TagIsId( node, TidyTag_SUP )
229 #define nodeIsU( node )          TagIsId( node, TidyTag_U )
230 #define nodeIsMENU( node )       TagIsId( node, TidyTag_MENU )
231 #define nodeIsBUTTON( node )     TagIsId( node, TidyTag_BUTTON )
232 
233 
234 #endif /* __TAGS_H__ */
235 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.