merge with with balthisar/tidy-html5 repo

This commit is contained in:
Geoff McLane 2015-01-18 12:25:20 +01:00
commit 995a6122f2
16 changed files with 13001 additions and 8165 deletions

14
.gitignore vendored
View file

@ -1,3 +1,5 @@
/build/gmake/obj/
/bin/
/build/msvc2010/Obj/ /build/msvc2010/Obj/
/build/msvc2010/Debugtidydll/ /build/msvc2010/Debugtidydll/
/build/msvc2010/Debugtidylib/ /build/msvc2010/Debugtidylib/
@ -5,6 +7,18 @@
/build/msvc2010/Releasetidydll/ /build/msvc2010/Releasetidydll/
/build/msvc2010/Releasetidylib/ /build/msvc2010/Releasetidylib/
/build/msvc2010/Release/ /build/msvc2010/Release/
/build/msvc2010/ipch/
/build/msvc2010/tidy.opensdf
/htmldoc/tidy-config.xml
/htmldoc/tidy-help.xml
/htmldoc/tidy.1
/htmldoc/quickref.html
/lib/
/autom4te.cache/
/console/.deps/
/console/.libs/
/src/.deps/
/src/.libs/
*.user *.user
*.suo *.suo
*.sdf *.sdf

View file

@ -477,6 +477,10 @@ extern "C" {
#define access _access #define access _access
#define strcasecmp _stricmp #define strcasecmp _stricmp
#ifndef va_copy
#define va_copy(dest, src) (dest = src)
#endif
#if _MSC_VER > 1000 #if _MSC_VER > 1000
#pragma warning( disable : 4189 ) /* local variable is initialized but not referenced */ #pragma warning( disable : 4189 ) /* local variable is initialized but not referenced */
#pragma warning( disable : 4100 ) /* unreferenced formal parameter */ #pragma warning( disable : 4100 ) /* unreferenced formal parameter */

6
include/tidy.h Normal file → Executable file
View file

@ -619,10 +619,16 @@ TIDY_EXPORT void TIDY_CALL tidyPutByte( TidyOutputSink* sink, uint byteValue );
typedef Bool (TIDY_CALL *TidyReportFilter)( TidyDoc tdoc, TidyReportLevel lvl, typedef Bool (TIDY_CALL *TidyReportFilter)( TidyDoc tdoc, TidyReportLevel lvl,
uint line, uint col, ctmbstr mssg ); uint line, uint col, ctmbstr mssg );
typedef Bool (TIDY_CALL *TidyReportFilter2)( TidyDoc tdoc, TidyReportLevel lvl,
uint line, uint col, ctmbstr mssg, va_list args );
/** Give Tidy a filter callback to use */ /** Give Tidy a filter callback to use */
TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc, TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc,
TidyReportFilter filtCallback ); TidyReportFilter filtCallback );
TIDY_EXPORT Bool TIDY_CALL tidySetReportFilter2( TidyDoc tdoc,
TidyReportFilter2 filtCallback );
/** Set error sink to named file */ /** Set error sink to named file */
TIDY_EXPORT FILE* TIDY_CALL tidySetErrorFile( TidyDoc tdoc, ctmbstr errfilnam ); TIDY_EXPORT FILE* TIDY_CALL tidySetErrorFile( TidyDoc tdoc, ctmbstr errfilnam );
/** Set error sink to given buffer */ /** Set error sink to given buffer */

View file

@ -542,7 +542,11 @@ typedef enum
TidyAttr_HTTP_EQUIV, /**< HTTP_EQUIV= */ TidyAttr_HTTP_EQUIV, /**< HTTP_EQUIV= */
TidyAttr_ID, /**< ID= */ TidyAttr_ID, /**< ID= */
TidyAttr_ISMAP, /**< ISMAP= */ TidyAttr_ISMAP, /**< ISMAP= */
TidyAttr_ITEMID, /**< ITEMID= */
TidyAttr_ITEMPROP, /**< ITEMPROP= */ TidyAttr_ITEMPROP, /**< ITEMPROP= */
TidyAttr_ITEMREF, /**< ITEMREF= */
TidyAttr_ITEMSCOPE, /**< ITEMSCOPE= */
TidyAttr_ITEMTYPE, /**< ITEMTYPE= */
TidyAttr_LABEL, /**< LABEL= */ TidyAttr_LABEL, /**< LABEL= */
TidyAttr_LANG, /**< LANG= */ TidyAttr_LANG, /**< LANG= */
TidyAttr_LANGUAGE, /**< LANGUAGE= */ TidyAttr_LANGUAGE, /**< LANGUAGE= */
@ -598,6 +602,7 @@ typedef enum
TidyAttr_REL, /**< REL= */ TidyAttr_REL, /**< REL= */
TidyAttr_REV, /**< REV= */ TidyAttr_REV, /**< REV= */
TidyAttr_RIGHTMARGIN, /**< RIGHTMARGIN= */ TidyAttr_RIGHTMARGIN, /**< RIGHTMARGIN= */
TidyAttr_ROLE, /**< ROLE= */
TidyAttr_ROWS, /**< ROWS= */ TidyAttr_ROWS, /**< ROWS= */
TidyAttr_ROWSPAN, /**< ROWSPAN= */ TidyAttr_ROWSPAN, /**< ROWSPAN= */
TidyAttr_RULES, /**< RULES= */ TidyAttr_RULES, /**< RULES= */
@ -742,6 +747,43 @@ typedef enum
TidyAttr_SRCDOC, TidyAttr_SRCDOC,
TidyAttr_SRCLANG, TidyAttr_SRCLANG,
TidyAttr_STEP, TidyAttr_STEP,
TidyAttr_ARIA_ACTIVEDESCENDANT,
TidyAttr_ARIA_ATOMIC,
TidyAttr_ARIA_AUTOCOMPLETE,
TidyAttr_ARIA_BUSY,
TidyAttr_ARIA_CHECKED,
TidyAttr_ARIA_CONTROLS,
TidyAttr_ARIA_DESCRIBEDBY,
TidyAttr_ARIA_DISABLED,
TidyAttr_ARIA_DROPEFFECT,
TidyAttr_ARIA_EXPANDED,
TidyAttr_ARIA_FLOWTO,
TidyAttr_ARIA_GRABBED,
TidyAttr_ARIA_HASPOPUP,
TidyAttr_ARIA_HIDDEN,
TidyAttr_ARIA_INVALID,
TidyAttr_ARIA_LABEL,
TidyAttr_ARIA_LABELLEDBY,
TidyAttr_ARIA_LEVEL,
TidyAttr_ARIA_LIVE,
TidyAttr_ARIA_MULTILINE,
TidyAttr_ARIA_MULTISELECTABLE,
TidyAttr_ARIA_ORIENTATION,
TidyAttr_ARIA_OWNS,
TidyAttr_ARIA_POSINSET,
TidyAttr_ARIA_PRESSED,
TidyAttr_ARIA_READONLY,
TidyAttr_ARIA_RELEVANT,
TidyAttr_ARIA_REQUIRED,
TidyAttr_ARIA_SELECTED,
TidyAttr_ARIA_SETSIZE,
TidyAttr_ARIA_SORT,
TidyAttr_ARIA_VALUEMAX,
TidyAttr_ARIA_VALUEMIN,
TidyAttr_ARIA_VALUENOW,
TidyAttr_ARIA_VALUETEXT,
N_TIDY_ATTRIBS /**< Must be last */ N_TIDY_ATTRIBS /**< Must be last */
@ -751,3 +793,4 @@ typedef enum
} /* extern "C" */ } /* extern "C" */
#endif #endif
#endif /* __TIDYENUM_H__ */ #endif /* __TIDYENUM_H__ */

File diff suppressed because it is too large Load diff

View file

@ -152,7 +152,11 @@ static const Attribute attribute_defs [] =
{ TidyAttr_HTTP_EQUIV, "http-equiv", CH_PCDATA }, /* META */ { TidyAttr_HTTP_EQUIV, "http-equiv", CH_PCDATA }, /* META */
{ TidyAttr_ID, "id", CH_IDDEF }, { TidyAttr_ID, "id", CH_IDDEF },
{ TidyAttr_ISMAP, "ismap", CH_BOOL }, /* IMG */ { TidyAttr_ISMAP, "ismap", CH_BOOL }, /* IMG */
{ TidyAttr_ITEMID, "itemid", CH_PCDATA },
{ TidyAttr_ITEMPROP, "itemprop", CH_PCDATA }, { TidyAttr_ITEMPROP, "itemprop", CH_PCDATA },
{ TidyAttr_ITEMREF, "itemref", CH_PCDATA },
{ TidyAttr_ITEMSCOPE, "itemscope", CH_BOOL },
{ TidyAttr_ITEMTYPE, "itemtype", CH_URL },
{ TidyAttr_LABEL, "label", CH_PCDATA }, /* OPT, OPTGROUP */ { TidyAttr_LABEL, "label", CH_PCDATA }, /* OPT, OPTGROUP */
{ TidyAttr_LANG, "lang", CH_LANG }, { TidyAttr_LANG, "lang", CH_LANG },
{ TidyAttr_LANGUAGE, "language", CH_PCDATA }, /* SCRIPT */ { TidyAttr_LANGUAGE, "language", CH_PCDATA }, /* SCRIPT */
@ -208,6 +212,7 @@ static const Attribute attribute_defs [] =
{ TidyAttr_REL, "rel", CH_LINKTYPES }, { TidyAttr_REL, "rel", CH_LINKTYPES },
{ TidyAttr_REV, "rev", CH_LINKTYPES }, { TidyAttr_REV, "rev", CH_LINKTYPES },
{ TidyAttr_RIGHTMARGIN, "rightmargin", CH_NUMBER }, /* used on BODY */ { TidyAttr_RIGHTMARGIN, "rightmargin", CH_NUMBER }, /* used on BODY */
{ TidyAttr_ROLE, "role", CH_PCDATA },
{ TidyAttr_ROWS, "rows", CH_NUMBER }, /* TEXTAREA */ { TidyAttr_ROWS, "rows", CH_NUMBER }, /* TEXTAREA */
{ TidyAttr_ROWSPAN, "rowspan", CH_NUMBER }, /* table cells */ { TidyAttr_ROWSPAN, "rowspan", CH_NUMBER }, /* table cells */
{ TidyAttr_RULES, "rules", CH_TRULES }, /* TABLE */ { TidyAttr_RULES, "rules", CH_TRULES }, /* TABLE */
@ -355,6 +360,43 @@ static const Attribute attribute_defs [] =
{ TidyAttr_SRCLANG, "srclang", CH_PCDATA }, { TidyAttr_SRCLANG, "srclang", CH_PCDATA },
{ TidyAttr_STEP, "step", CH_PCDATA }, { TidyAttr_STEP, "step", CH_PCDATA },
/* HTML5 Aria Attributes */
{ TidyAttr_ARIA_ACTIVEDESCENDANT, "aria-activedescendant", CH_PCDATA },
{ TidyAttr_ARIA_ATOMIC, "aria-atomic", CH_PCDATA },
{ TidyAttr_ARIA_AUTOCOMPLETE, "aria-autocomplete", CH_PCDATA },
{ TidyAttr_ARIA_BUSY, "aria-busy", CH_PCDATA },
{ TidyAttr_ARIA_CHECKED, "aria-checked", CH_PCDATA },
{ TidyAttr_ARIA_CONTROLS, "aria-controls", CH_PCDATA },
{ TidyAttr_ARIA_DESCRIBEDBY, "aria-describedby", CH_PCDATA },
{ TidyAttr_ARIA_DISABLED, "aria-disabled", CH_PCDATA },
{ TidyAttr_ARIA_DROPEFFECT, "aria-dropeffect", CH_PCDATA },
{ TidyAttr_ARIA_EXPANDED, "aria-expanded", CH_PCDATA },
{ TidyAttr_ARIA_FLOWTO, "aria-flowto", CH_PCDATA },
{ TidyAttr_ARIA_GRABBED, "aria-grabbed", CH_PCDATA },
{ TidyAttr_ARIA_HASPOPUP, "aria-haspopup", CH_PCDATA },
{ TidyAttr_ARIA_HIDDEN, "aria-hidden", CH_PCDATA },
{ TidyAttr_ARIA_INVALID, "aria-invalid", CH_PCDATA },
{ TidyAttr_ARIA_LABEL, "aria-label", CH_PCDATA },
{ TidyAttr_ARIA_LABELLEDBY, "aria-labelledby", CH_PCDATA },
{ TidyAttr_ARIA_LEVEL, "aria-level", CH_PCDATA },
{ TidyAttr_ARIA_LIVE, "aria-live", CH_PCDATA },
{ TidyAttr_ARIA_MULTILINE, "aria-multiline", CH_PCDATA },
{ TidyAttr_ARIA_MULTISELECTABLE, "aria-multiselectable", CH_PCDATA },
{ TidyAttr_ARIA_ORIENTATION, "aria-orientation", CH_PCDATA },
{ TidyAttr_ARIA_OWNS, "aria-owns", CH_PCDATA },
{ TidyAttr_ARIA_POSINSET, "aria-posinset", CH_PCDATA },
{ TidyAttr_ARIA_PRESSED, "aria-pressed", CH_PCDATA },
{ TidyAttr_ARIA_READONLY, "aria-readonly", CH_PCDATA },
{ TidyAttr_ARIA_RELEVANT, "aria-relevant", CH_PCDATA },
{ TidyAttr_ARIA_REQUIRED, "aria-required", CH_PCDATA },
{ TidyAttr_ARIA_SELECTED, "aria-selected", CH_PCDATA },
{ TidyAttr_ARIA_SETSIZE, "aria-setsize", CH_PCDATA },
{ TidyAttr_ARIA_SORT, "aria-sort", CH_PCDATA },
{ TidyAttr_ARIA_VALUEMAX, "aria-valuemax", CH_PCDATA },
{ TidyAttr_ARIA_VALUEMIN, "aria-valuemin", CH_PCDATA },
{ TidyAttr_ARIA_VALUENOW, "aria-valuenow", CH_PCDATA },
{ TidyAttr_ARIA_VALUETEXT, "aria-valuetext", CH_PCDATA },
/* this must be the final entry */ /* this must be the final entry */
{ N_TIDY_ATTRIBS, NULL, NULL } { N_TIDY_ATTRIBS, NULL, NULL }
}; };
@ -900,20 +942,33 @@ static void FreeAnchor(TidyDocImpl* doc, Anchor *a)
TidyDocFree( doc, a ); TidyDocFree( doc, a );
} }
static uint anchorNameHash(ctmbstr s)
{
uint hashval;
for (hashval = 0; *s != '\0'; s++) {
tmbchar c = TY_(ToLower)( *s );
hashval = c + 31*hashval;
}
return hashval % ANCHOR_HASH_SIZE;
}
/* removes anchor for specific node */ /* removes anchor for specific node */
void TY_(RemoveAnchorByNode)( TidyDocImpl* doc, Node *node ) void TY_(RemoveAnchorByNode)( TidyDocImpl* doc, ctmbstr name, Node *node )
{ {
TidyAttribImpl* attribs = &doc->attribs; TidyAttribImpl* attribs = &doc->attribs;
Anchor *delme = NULL, *curr, *prev = NULL; Anchor *delme = NULL, *curr, *prev = NULL;
uint h = anchorNameHash(name);
for ( curr=attribs->anchor_list; curr!=NULL; curr=curr->next ) for ( curr=attribs->anchor_hash[h]; curr!=NULL; curr=curr->next )
{ {
if ( curr->node == node ) if ( curr->node == node )
{ {
if ( prev ) if ( prev )
prev->next = curr->next; prev->next = curr->next;
else else
attribs->anchor_list = curr->next; attribs->anchor_hash[h] = curr->next;
delme = curr; delme = curr;
break; break;
} }
@ -940,18 +995,19 @@ static Anchor* AddAnchor( TidyDocImpl* doc, ctmbstr name, Node *node )
{ {
TidyAttribImpl* attribs = &doc->attribs; TidyAttribImpl* attribs = &doc->attribs;
Anchor *a = NewAnchor( doc, name, node ); Anchor *a = NewAnchor( doc, name, node );
uint h = anchorNameHash(name);
if ( attribs->anchor_list == NULL) if ( attribs->anchor_hash[h] == NULL)
attribs->anchor_list = a; attribs->anchor_hash[h] = a;
else else
{ {
Anchor *here = attribs->anchor_list; Anchor *here = attribs->anchor_hash[h];
while (here->next) while (here->next)
here = here->next; here = here->next;
here->next = a; here->next = a;
} }
return attribs->anchor_list; return attribs->anchor_hash[h];
} }
/* return node associated with anchor */ /* return node associated with anchor */
@ -959,10 +1015,11 @@ static Node* GetNodeByAnchor( TidyDocImpl* doc, ctmbstr name )
{ {
TidyAttribImpl* attribs = &doc->attribs; TidyAttribImpl* attribs = &doc->attribs;
Anchor *found; Anchor *found;
uint h = anchorNameHash(name);
tmbstr lname = TY_(tmbstrdup)(doc->allocator, name); tmbstr lname = TY_(tmbstrdup)(doc->allocator, name);
lname = TY_(tmbstrtolower)(lname); lname = TY_(tmbstrtolower)(lname);
for ( found = attribs->anchor_list; found != NULL; found = found->next ) for ( found = attribs->anchor_hash[h]; found != NULL; found = found->next )
{ {
if ( TY_(tmbstrcmp)(found->name, lname) == 0 ) if ( TY_(tmbstrcmp)(found->name, lname) == 0 )
break; break;
@ -979,12 +1036,15 @@ void TY_(FreeAnchors)( TidyDocImpl* doc )
{ {
TidyAttribImpl* attribs = &doc->attribs; TidyAttribImpl* attribs = &doc->attribs;
Anchor* a; Anchor* a;
while (NULL != (a = attribs->anchor_list) ) uint h;
for (h = 0; h < ANCHOR_HASH_SIZE; h++) {
while (NULL != (a = attribs->anchor_hash[h]) )
{ {
attribs->anchor_list = a->next; attribs->anchor_hash[h] = a->next;
FreeAnchor(doc, a); FreeAnchor(doc, a);
} }
} }
}
/* public method for inititializing attribute dictionary */ /* public method for inititializing attribute dictionary */
void TY_(InitAttrs)( TidyDocImpl* doc ) void TY_(InitAttrs)( TidyDocImpl* doc )

View file

@ -55,10 +55,15 @@ struct _AttrHash
typedef struct _AttrHash AttrHash; typedef struct _AttrHash AttrHash;
#endif #endif
enum
{
ANCHOR_HASH_SIZE=1021u
};
struct _TidyAttribImpl struct _TidyAttribImpl
{ {
/* anchor/node lookup */ /* anchor/node lookup */
Anchor* anchor_list; Anchor* anchor_hash[ANCHOR_HASH_SIZE];
/* Declared literal attributes */ /* Declared literal attributes */
Attribute* declared_attr_list; Attribute* declared_attr_list;
@ -117,7 +122,7 @@ Bool TY_(IsValidHTMLID)(ctmbstr id);
Bool TY_(IsValidXMLID)(ctmbstr id); Bool TY_(IsValidXMLID)(ctmbstr id);
/* removes anchor for specific node */ /* removes anchor for specific node */
void TY_(RemoveAnchorByNode)( TidyDocImpl* doc, Node *node ); void TY_(RemoveAnchorByNode)( TidyDocImpl* doc, ctmbstr name, Node *node );
/* free all anchors */ /* free all anchors */
void TY_(FreeAnchors)( TidyDocImpl* doc ); void TY_(FreeAnchors)( TidyDocImpl* doc );
@ -219,7 +224,11 @@ uint TY_(NodeAttributeVersions)( Node* node, TidyAttrId id );
#define attrIsHTTP_EQUIV(av) AttrIsId( av, TidyAttr_HTTP_EQUIV ) #define attrIsHTTP_EQUIV(av) AttrIsId( av, TidyAttr_HTTP_EQUIV )
#define attrIsID(av) AttrIsId( av, TidyAttr_ID ) #define attrIsID(av) AttrIsId( av, TidyAttr_ID )
#define attrIsISMAP(av) AttrIsId( av, TidyAttr_ISMAP ) #define attrIsISMAP(av) AttrIsId( av, TidyAttr_ISMAP )
#define attrIsITEMID(av) AttrIsId( av, TidyAttr_ITEMID )
#define attrIsITEMPROP(av) AttrIsId( av, TidyAttr_ITEMPROP ) #define attrIsITEMPROP(av) AttrIsId( av, TidyAttr_ITEMPROP )
#define attrIsITEMREF(av) AttrIsId( av, TidyAttr_ITEMREF )
#define attrIsITEMSCOPE(av) AttrIsId( av, TidyAttr_ITEMSCOPE )
#define attrIsITEMTYPE(av) AttrIsId( av, TidyAttr_ITEMTYPE )
#define attrIsLABEL(av) AttrIsId( av, TidyAttr_LABEL ) #define attrIsLABEL(av) AttrIsId( av, TidyAttr_LABEL )
#define attrIsLANG(av) AttrIsId( av, TidyAttr_LANG ) #define attrIsLANG(av) AttrIsId( av, TidyAttr_LANG )
#define attrIsLANGUAGE(av) AttrIsId( av, TidyAttr_LANGUAGE ) #define attrIsLANGUAGE(av) AttrIsId( av, TidyAttr_LANGUAGE )
@ -275,6 +284,7 @@ uint TY_(NodeAttributeVersions)( Node* node, TidyAttrId id );
#define attrIsREL(av) AttrIsId( av, TidyAttr_REL ) #define attrIsREL(av) AttrIsId( av, TidyAttr_REL )
#define attrIsREV(av) AttrIsId( av, TidyAttr_REV ) #define attrIsREV(av) AttrIsId( av, TidyAttr_REV )
#define attrIsRIGHTMARGIN(av) AttrIsId( av, TidyAttr_RIGHTMARGIN ) #define attrIsRIGHTMARGIN(av) AttrIsId( av, TidyAttr_RIGHTMARGIN )
#define attrIsROLE(av) AttrIsId( av, TidyAttr_ROLE )
#define attrIsROWS(av) AttrIsId( av, TidyAttr_ROWS ) #define attrIsROWS(av) AttrIsId( av, TidyAttr_ROWS )
#define attrIsROWSPAN(av) AttrIsId( av, TidyAttr_ROWSPAN ) #define attrIsROWSPAN(av) AttrIsId( av, TidyAttr_ROWSPAN )
#define attrIsRULES(av) AttrIsId( av, TidyAttr_RULES ) #define attrIsRULES(av) AttrIsId( av, TidyAttr_RULES )
@ -311,6 +321,42 @@ uint TY_(NodeAttributeVersions)( Node* node, TidyAttrId id );
#define attrIsXMLNS(av) AttrIsId( av, TidyAttr_XMLNS ) #define attrIsXMLNS(av) AttrIsId( av, TidyAttr_XMLNS )
#define attrIsXML_LANG(av) AttrIsId( av, TidyAttr_XML_LANG ) #define attrIsXML_LANG(av) AttrIsId( av, TidyAttr_XML_LANG )
#define attrIsXML_SPACE(av) AttrIsId( av, TidyAttr_XML_SPACE ) #define attrIsXML_SPACE(av) AttrIsId( av, TidyAttr_XML_SPACE )
#define attrIsARIA_ACTIVEDESCENDANT(av) AttrIsId( av, TidyAttr_ARIA_ACTIVEDESCENDANT )
#define attrIsARIA_ATOMIC(av) AttrIsId( av, TidyAttr_ARIA_ATOMIC )
#define attrIsARIA_AUTOCOMPLETE(av) AttrIsId( av, TidyAttr_ARIA_AUTOCOMPLETE )
#define attrIsARIA_BUSY(av) AttrIsId( av, TidyAttr_ARIA_BUSY )
#define attrIsARIA_CHECKED(av) AttrIsId( av, TidyAttr_ARIA_CHECKED )
#define attrIsARIA_CONTROLS(av) AttrIsId( av, TidyAttr_ARIA_CONTROLS )
#define attrIsARIA_DESCRIBEDBY(av) AttrIsId( av, TidyAttr_ARIA_DESCRIBEDBY )
#define attrIsARIA_DISABLED(av) AttrIsId( av, TidyAttr_ARIA_DISABLED )
#define attrIsARIA_DROPEFFECT(av) AttrIsId( av, TidyAttr_ARIA_DROPEFFECT )
#define attrIsARIA_EXPANDED(av) AttrIsId( av, TidyAttr_ARIA_EXPANDED )
#define attrIsARIA_FLOWTO(av) AttrIsId( av, TidyAttr_ARIA_FLOWTO )
#define attrIsARIA_GRABBED(av) AttrIsId( av, TidyAttr_ARIA_GRABBED )
#define attrIsARIA_HASPOPUP(av) AttrIsId( av, TidyAttr_ARIA_HASPOPUP )
#define attrIsARIA_HIDDEN(av) AttrIsId( av, TidyAttr_ARIA_HIDDEN )
#define attrIsARIA_INVALID(av) AttrIsId( av, TidyAttr_ARIA_INVALID )
#define attrIsARIA_LABEL(av) AttrIsId( av, TidyAttr_ARIA_LABEL )
#define attrIsARIA_LABELLEDBY(av) AttrIsId( av, TidyAttr_ARIA_LABELLEDBY )
#define attrIsARIA_LEVEL(av) AttrIsId( av, TidyAttr_ARIA_LEVEL )
#define attrIsARIA_LIVE(av) AttrIsId( av, TidyAttr_ARIA_LIVE )
#define attrIsARIA_MULTILINE(av) AttrIsId( av, TidyAttr_ARIA_MULTILINE )
#define attrIsARIA_MULTISELECTABLE(av) AttrIsId( av, TidyAttr_ARIA_MULTISELECTABLE )
#define attrIsARIA_ORIENTATION(av) AttrIsId( av, TidyAttr_ARIA_ORIENTATION )
#define attrIsARIA_OWNS(av) AttrIsId( av, TidyAttr_ARIA_OWNS )
#define attrIsARIA_POSINSET(av) AttrIsId( av, TidyAttr_ARIA_POSINSET )
#define attrIsARIA_PRESSED(av) AttrIsId( av, TidyAttr_ARIA_PRESSED )
#define attrIsARIA_READONLY(av) AttrIsId( av, TidyAttr_ARIA_READONLY )
#define attrIsARIA_RELEVANT(av) AttrIsId( av, TidyAttr_ARIA_RELEVANT )
#define attrIsARIA_REQUIRED(av) AttrIsId( av, TidyAttr_ARIA_REQUIRED )
#define attrIsARIA_SELECTED(av) AttrIsId( av, TidyAttr_ARIA_SELECTED )
#define attrIsARIA_SETSIZE(av) AttrIsId( av, TidyAttr_ARIA_SETSIZE )
#define attrIsARIA_SORT(av) AttrIsId( av, TidyAttr_ARIA_SORT )
#define attrIsARIA_VALUEMAX(av) AttrIsId( av, TidyAttr_ARIA_VALUEMAX )
#define attrIsARIA_VALUEMIN(av) AttrIsId( av, TidyAttr_ARIA_VALUEMIN )
#define attrIsARIA_VALUENOW(av) AttrIsId( av, TidyAttr_ARIA_VALUENOW )
#define attrIsARIA_VALUETEXT(av) AttrIsId( av, TidyAttr_ARIA_VALUETEXT )
/* Attribute Retrieval macros /* Attribute Retrieval macros
@ -367,4 +413,42 @@ uint TY_(NodeAttributeVersions)( Node* node, TidyAttrId id );
#define attrGetBASEFONT( nod ) TY_(AttrGetById)( nod, TidyAttr_BASEFONT ) #define attrGetBASEFONT( nod ) TY_(AttrGetById)( nod, TidyAttr_BASEFONT )
#define attrGetROWSPAN( nod ) TY_(AttrGetById)( nod, TidyAttr_ROWSPAN ) #define attrGetROWSPAN( nod ) TY_(AttrGetById)( nod, TidyAttr_ROWSPAN )
#define attrGetROLE( nod ) TY_(AttrGetById)( nod, TidyAttr_ROLE )
#define attrGetARIA_ACTIVEDESCENDANT( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_ACTIVEDESCENDANT )
#define attrGetARIA_ATOMIC( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_ATOMIC )
#define attrGetARIA_AUTOCOMPLETE( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_AUTOCOMPLETE )
#define attrGetARIA_BUSY( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_BUSY )
#define attrGetARIA_CHECKED( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_CHECKED )
#define attrGetARIA_CONTROLS( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_CONTROLS )
#define attrGetARIA_DESCRIBEDBY( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_DESCRIBEDBY )
#define attrGetARIA_DISABLED( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_DISABLED )
#define attrGetARIA_DROPEFFECT( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_DROPEFFECT )
#define attrGetARIA_EXPANDED( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_EXPANDED )
#define attrGetARIA_FLOWTO( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_FLOWTO )
#define attrGetARIA_GRABBED( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_GRABBED )
#define attrGetARIA_HASPOPUP( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_HASPOPUP )
#define attrGetARIA_HIDDEN( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_HIDDEN )
#define attrGetARIA_INVALID( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_INVALID )
#define attrGetARIA_LABEL( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_LABEL )
#define attrGetARIA_LABELLEDBY( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_LABELLEDBY )
#define attrGetARIA_LEVEL( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_LEVEL )
#define attrGetARIA_LIVE( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_LIVE )
#define attrGetARIA_MULTILINE( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_MULTILINE )
#define attrGetARIA_MULTISELECTABLE( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_MULTISELECTABLE )
#define attrGetARIA_ORIENTATION( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_ORIENTATION )
#define attrGetARIA_OWNS( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_OWNS )
#define attrGetARIA_POSINSET( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_POSINSET )
#define attrGetARIA_PRESSED( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_PRESSED )
#define attrGetARIA_READONLY( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_READONLY )
#define attrGetARIA_RELEVANT( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_RELEVANT )
#define attrGetARIA_REQUIRED( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_REQUIRED )
#define attrGetARIA_SELECTED( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_SELECTED )
#define attrGetARIA_SETSIZE( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_SETSIZE )
#define attrGetARIA_SORT( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_SORT )
#define attrGetARIA_VALUEMAX( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_VALUEMAX )
#define attrGetARIA_VALUEMIN( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_VALUEMIN )
#define attrGetARIA_VALUENOW( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_VALUENOW )
#define attrGetARIA_VALUETEXT( nod ) TY_(AttrGetById)( nod, TidyAttr_ARIA_VALUETEXT )
#endif /* __ATTRS_H__ */ #endif /* __ATTRS_H__ */

View file

@ -2638,17 +2638,19 @@ void TY_(FixAnchors)(TidyDocImpl* doc, Node *node, Bool wantName, Bool wantId)
if (id && !wantId if (id && !wantId
/* make sure that Name has been emitted if requested */ /* make sure that Name has been emitted if requested */
&& (hadName || !wantName || NameEmitted) ) && (hadName || !wantName || NameEmitted) ) {
if (!wantId && !wantName)
TY_(RemoveAnchorByNode)(doc, id->value, node);
TY_(RemoveAttribute)(doc, node, id); TY_(RemoveAttribute)(doc, node, id);
}
if (name && !wantName if (name && !wantName
/* make sure that Id has been emitted if requested */ /* make sure that Id has been emitted if requested */
&& (hadId || !wantId || IdEmitted) ) && (hadId || !wantId || IdEmitted) ) {
if (!wantId && !wantName)
TY_(RemoveAnchorByNode)(doc, name->value, node);
TY_(RemoveAttribute)(doc, node, name); TY_(RemoveAttribute)(doc, node, name);
}
if (TY_(AttrGetById)(node, TidyAttr_NAME) == NULL &&
TY_(AttrGetById)(node, TidyAttr_ID) == NULL)
TY_(RemoveAnchorByNode)(doc, node);
} }
if (node->content) if (node->content)

View file

@ -1128,7 +1128,7 @@ void TY_(FreeAttrs)( TidyDocImpl* doc, Node *node )
if ( (attrIsID(av) || attrIsNAME(av)) && if ( (attrIsID(av) || attrIsNAME(av)) &&
TY_(IsAnchorElement)(doc, node) ) TY_(IsAnchorElement)(doc, node) )
{ {
TY_(RemoveAnchorByNode)( doc, node ); TY_(RemoveAnchorByNode)( doc, av->value, node );
} }
} }

7
src/localize.c Normal file → Executable file
View file

@ -1035,12 +1035,19 @@ static void messagePos( TidyDocImpl* doc, TidyReportLevel level,
if ( go ) if ( go )
{ {
va_list args_copy;
va_copy(args_copy, args);
TY_(tmbvsnprintf)(messageBuf, sizeMessageBuf, msg, args); TY_(tmbvsnprintf)(messageBuf, sizeMessageBuf, msg, args);
if ( doc->mssgFilt ) if ( doc->mssgFilt )
{ {
TidyDoc tdoc = tidyImplToDoc( doc ); TidyDoc tdoc = tidyImplToDoc( doc );
go = doc->mssgFilt( tdoc, level, line, col, messageBuf ); go = doc->mssgFilt( tdoc, level, line, col, messageBuf );
} }
if ( doc->mssgFilt2 )
{
TidyDoc tdoc = tidyImplToDoc( doc );
go = go | doc->mssgFilt2( tdoc, level, line, col, msg, args_copy );
}
} }
if ( go ) if ( go )

0
src/mappedio.c Executable file → Normal file
View file

0
src/mappedio.h Executable file → Normal file
View file

View file

@ -1302,6 +1302,9 @@ static Bool AfterSpace(Lexer *lexer, Node *node)
return AfterSpaceImp(lexer, node, TY_(nodeCMIsEmpty)(node)); return AfterSpaceImp(lexer, node, TY_(nodeCMIsEmpty)(node));
} }
static void PPrintEndTag( TidyDocImpl* doc, uint ARG_UNUSED(mode),
uint ARG_UNUSED(indent), Node *node );
static void PPrintTag( TidyDocImpl* doc, static void PPrintTag( TidyDocImpl* doc,
uint mode, uint indent, Node *node ) uint mode, uint indent, Node *node )
{ {
@ -1344,7 +1347,12 @@ static void PPrintTag( TidyDocImpl* doc,
AddChar( pprint, '>' ); AddChar( pprint, '>' );
if ( (node->type != StartEndTag || xhtmlOut) && !(mode & PREFORMATTED) ) if (node->type == StartEndTag && TY_(HTMLVersion)(doc) == HT50)
{
PPrintEndTag( doc, mode, indent, node );
}
if ( (node->type != StartEndTag || xhtmlOut || (node->type == StartEndTag && TY_(HTMLVersion)(doc) == HT50)) && !(mode & PREFORMATTED) )
{ {
uint wraplen = cfg( doc, TidyWrapLen ); uint wraplen = cfg( doc, TidyWrapLen );
CheckWrapIndent( doc, indent ); CheckWrapIndent( doc, indent );

1
src/tidy-int.h Normal file → Executable file
View file

@ -48,6 +48,7 @@ struct _TidyDocImpl
StreamOut* docOut; StreamOut* docOut;
StreamOut* errout; StreamOut* errout;
TidyReportFilter mssgFilt; TidyReportFilter mssgFilt;
TidyReportFilter2 mssgFilt2;
TidyOptCallback pOptCallback; TidyOptCallback pOptCallback;
/* Parse + Repair Results */ /* Parse + Repair Results */

11
src/tidylib.c Normal file → Executable file
View file

@ -650,6 +650,17 @@ Bool TIDY_CALL tidySetReportFilter( TidyDoc tdoc, TidyReportFilter filt )
return no; return no;
} }
Bool TIDY_CALL tidySetReportFilter2( TidyDoc tdoc, TidyReportFilter2 filt )
{
TidyDocImpl* impl = tidyDocToImpl( tdoc );
if ( impl )
{
impl->mssgFilt2 = filt;
return yes;
}
return no;
}
#if 0 /* Not yet */ #if 0 /* Not yet */
int tidySetContentOutputSink( TidyDoc tdoc, TidyOutputSink* outp ) int tidySetContentOutputSink( TidyDoc tdoc, TidyOutputSink* outp )
{ {

0
src/version.h Executable file → Normal file
View file