diff --git a/src/localize.c b/src/localize.c index f1c35ab..63e43b8 100755 --- a/src/localize.c +++ b/src/localize.c @@ -113,7 +113,8 @@ static struct _msgfmt /* HTML5 */ { REMOVED_HTML5, "%s element removed from HTML5" }, /* Warning */ { BAD_BODY_HTML5, "Found attribute on body that is obsolete in HTML5. Use CSS" }, /* Warning */ - { BAD_ALIGN_HTML5, "The align attribute on the %s element is obsolete, Use CSS" }, /* Wanring */ + { BAD_ALIGN_HTML5, "The align attribute on the %s element is obsolete, Use CSS" }, /* Warning */ + { BAD_SUMMARY_HTML5, "The summary attribute on the %s element is obsolete in HTML5" }, /* Warning */ /* ReportNotice */ { TRIM_EMPTY_ELEMENT, "trimming empty %s" }, /* Notice */ @@ -1499,6 +1500,7 @@ void TY_(ReportWarning)(TidyDocImpl* doc, Node *element, Node *node, uint code) case REMOVED_HTML5: case BAD_BODY_HTML5: case BAD_ALIGN_HTML5: + case BAD_SUMMARY_HTML5: messageNode(doc, TidyWarning, rpt, fmt, nodedesc); break; case COERCE_TO_ENDTAG_WARN: diff --git a/src/message.h b/src/message.h index 13e6368..4ef7404 100644 --- a/src/message.h +++ b/src/message.h @@ -157,8 +157,9 @@ void TY_(ReportFatal)(TidyDocImpl* doc, Node* element, Node* node, uint code); #define REMOVED_HTML5 88 /* this element removed from HTML5 */ #define BAD_BODY_HTML5 89 /* attr on body removed from HTML5 */ #define BAD_ALIGN_HTML5 90 /* use of align attr removed from HTML5 */ +#define BAD_SUMMARY_HTML5 91 /* use of summary attr removed from HTML5 */ -#define PREVIOUS_LOCATION 91 /* last */ +#define PREVIOUS_LOCATION 92 /* last */ /* character encoding errors */ diff --git a/src/tags.c b/src/tags.c index a1a54d9..5470831 100644 --- a/src/tags.c +++ b/src/tags.c @@ -873,9 +873,29 @@ void CheckAREA( TidyDocImpl* doc, Node *node ) void CheckTABLE( TidyDocImpl* doc, Node *node ) { AttVal* attval; + Bool HasSummary = (TY_(AttrGetById)(node, TidyAttr_SUMMARY) != NULL) ? yes : no; + Bool isHTML5 = (TY_(HTMLVersion)(doc) == HT50) ? yes : no; TY_(CheckAttributes)(doc, node); + /* Issue #210 - a missing summary attribute is bad accessibility, no matter + what HTML version is involved; a document without is valid + EXCEPT for HTML5, when to have a summary is wrong */ + if (cfg(doc, TidyAccessibilityCheckLevel) == 0) + { + if (HasSummary && isHTML5) + { + /* #210 - has summary, and is HTML5, then report obsolete */ + TY_(ReportWarning)(doc, node, node, BAD_SUMMARY_HTML5); + } + else if (!HasSummary && !isHTML5) + { + /* #210 - No summary, and NOT HTML5, then report as before */ + doc->badAccess |= BA_MISSING_SUMMARY; + TY_(ReportMissingAttr)( doc, node, "summary"); + } + } + /* convert to
*/ if ( cfgBool(doc, TidyXmlOut) && (attval = TY_(AttrGetById)(node, TidyAttr_BORDER)) ) {