Merge pull request #370 from htacg/attrdict_phase1

Address #346 and shrink attrdict.c.
This commit is contained in:
Jim Derry 2016-02-16 11:08:53 +08:00
commit 813b12640e
7 changed files with 2786 additions and 13115 deletions

View file

@ -212,6 +212,7 @@ typedef enum
TidyAnchorAsName, /**< Define anchors as name attributes */
TidyPPrintTabs, /**< Indent using tabs istead of spaces */
TidySkipNested, /**< Skip nested tags in script and style CDATA */
TidyStrictTagsAttr, /**< Ensure tags and attributes match output HTML version */
N_TIDY_OPTIONS /**< Must be last */
} TidyOptionId;
@ -522,6 +523,7 @@ typedef enum
TidyAttr_ADD_DATE, /**< ADD_DATE= */
TidyAttr_ALIGN, /**< ALIGN= */
TidyAttr_ALINK, /**< ALINK= */
TidyAttr_ALLOWFULLSCREEN, /**< ALLOWFULLSCREEN= */
TidyAttr_ALT, /**< ALT= */
TidyAttr_ARCHIVE, /**< ARCHIVE= */
TidyAttr_AXIS, /**< AXIS= */
@ -662,6 +664,7 @@ typedef enum
TidyAttr_TEXT, /**< TEXT= */
TidyAttr_TITLE, /**< TITLE= */
TidyAttr_TOPMARGIN, /**< TOPMARGIN= */
TidyAttr_TRANSLATE, /**< TRANSLATE= */
TidyAttr_TYPE, /**< TYPE= */
TidyAttr_USEMAP, /**< USEMAP= */
TidyAttr_VALIGN, /**< VALIGN= */

File diff suppressed because it is too large Load diff

View file

@ -105,6 +105,7 @@ static const Attribute attribute_defs [] =
{ TidyAttr_ADD_DATE, "add_date", CH_PCDATA }, /* A */
{ TidyAttr_ALIGN, "align", CH_ALIGN }, /* varies by element */
{ TidyAttr_ALINK, "alink", CH_COLOR },
{ TidyAttr_ALLOWFULLSCREEN, "allowfullscreen", CH_BOOL },
{ TidyAttr_ALT, "alt", CH_PCDATA }, /* nowrap */
{ TidyAttr_ARCHIVE, "archive", CH_URLS }, /* space or comma separated list */
{ TidyAttr_AXIS, "axis", CH_PCDATA },
@ -245,6 +246,7 @@ static const Attribute attribute_defs [] =
{ TidyAttr_TEXT, "text", CH_COLOR }, /* BODY */
{ TidyAttr_TITLE, "title", CH_PCDATA }, /* text tool tip */
{ TidyAttr_TOPMARGIN, "topmargin", CH_NUMBER }, /* used on BODY */
{ TidyAttr_TRANSLATE, "translate", CH_BOOL }, /* HTML5 global attribute */
{ TidyAttr_TYPE, "type", CH_TYPE }, /* also used by SPACER */
{ TidyAttr_USEMAP, "usemap", CH_URL }, /* things with images */
{ TidyAttr_VALIGN, "valign", CH_VALIGN },
@ -338,7 +340,7 @@ static const Attribute attribute_defs [] =
{ TidyAttr_OnPOPSTATE, "onpopstate", CH_PCDATA },
{ TidyAttr_OnPROGRESS, "onprogress", CH_PCDATA },
{ TidyAttr_OnRATECHANGE, "onratechange", CH_PCDATA },
{ TidyAttr_OnREADYSTATECHANGE,"onreadystatechange", CH_PCDATA },
{ TidyAttr_OnREADYSTATECHANGE, "onreadystatechange", CH_PCDATA },
{ TidyAttr_OnREDO, "onredo", CH_PCDATA },
{ TidyAttr_OnRESIZE, "onresize", CH_PCDATA },
{ TidyAttr_OnSCROLL, "onscroll", CH_PCDATA },
@ -443,38 +445,11 @@ static uint AttributeVersions(Node* node, AttVal* attval)
{
uint i;
/* HTML5 data-* attributes
20150118: added allowfullscreen */
/* Override or add to items in attrdict.c */
if (attval && attval->attribute) {
/* HTML5 data-* attributes can't be added generically; handle here. */
if (TY_(tmbstrncmp)(attval->attribute, "data-", 5) == 0)
return (XH50 | HT50);
if (strcmp(attval->attribute,"allowfullscreen") == 0)
return (XH50 | HT50);
/* RDFa global attributes */
if (strcmp(attval->attribute,"about") == 0)
return (XH50 | HT50);
if (strcmp(attval->attribute,"datatype") == 0)
return (XH50 | HT50);
if (strcmp(attval->attribute,"inlist") == 0)
return (XH50 | HT50);
if (strcmp(attval->attribute,"prefix") == 0)
return (XH50 | HT50);
if (strcmp(attval->attribute,"property") == 0)
return (XH50 | HT50);
if (strcmp(attval->attribute,"resource") == 0)
return (XH50 | HT50);
if (strcmp(attval->attribute,"typeof") == 0)
return (XH50 | HT50);
if (strcmp(attval->attribute,"vocab") == 0)
return (XH50 | HT50);
/* Override the settings on these attributes because
* they are allowed everywhere by RDFa */
if (strcmp(attval->attribute,"content") == 0)
return (HT20|HT32|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10|HT50|XH50) ;
if (strcmp(attval->attribute,"rel") == 0)
return (HT20|HT32|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10|HT50|XH50) ;
if (strcmp(attval->attribute,"rev") == 0)
return (HT20|HT32|H40T|H41T|X10T|H40F|H41F|X10F|H40S|H41S|X10S|XH11|XB10|HT50|XH50) ;
}
/* TODO: maybe this should return VERS_PROPRIETARY instead? */
if (!attval || !attval->dict)
@ -505,7 +480,9 @@ uint TY_(NodeAttributeVersions)( Node* node, TidyAttrId id )
}
/* returns true if the element is a W3C defined element */
/* but the element/attribute combination is not */
/* but the element/attribute combination is not. We're */
/* only defining as "proprietary" items that are not in */
/* the element's AttrVersion structure. */
static Bool AttributeIsProprietary(Node* node, AttVal* attval)
{
if (!node || !attval)

View file

@ -322,6 +322,7 @@ static const TidyOptionImpl option_defs[] =
{ TidyAnchorAsName, MU, "anchor-as-name", BL, yes, ParseBool, boolPicks },
{ TidyPPrintTabs, PP, "indent-with-tabs", BL, no, ParseTabs, boolPicks }, /* 20150515 - Issue #108 */
{ TidySkipNested, MU, "skip-nested", BL, yes, ParseBool, boolPicks }, /* 1642186 - Issue #65 */
{ TidyStrictTagsAttr, MU, "strict-tags-attributes", BL, yes, ParseBool, boolPicks }, /* 20160209 - Issue #350 */
{ N_TIDY_OPTIONS, XX, NULL, XY, 0, NULL, NULL }
};

View file

@ -1791,7 +1791,7 @@ Bool TY_(SetXHTMLDocType)( TidyDocImpl* doc )
TY_(RepairAttrValue)(doc, doctype, sys, "");
break;
case TidyDoctypeAuto:
if (lexer->doctype == VERS_UNKNOWN) {
if (lexer->doctype == VERS_UNKNOWN || lexer->doctype == VERS_HTML5) {
lexer->versionEmitted = XH50;
return yes;
}
@ -1871,7 +1871,8 @@ Bool TY_(FixDocType)( TidyDocImpl* doc )
if (doctype && (dtmode == TidyDoctypeAuto) &&
(lexer->doctype == VERS_HTML5) )
{
lexer->versionEmitted = lexer->doctype;
/* The version emitted cannot be a composite value! */
lexer->versionEmitted = HT50;
return yes;
}
if (dtmode == TidyDoctypeAuto &&

View file

@ -211,6 +211,9 @@ typedef enum
#define VERS_FROM40 (VERS_HTML40|VERS_XHTML11|VERS_BASIC)
#define VERS_XHTML (X10S|X10T|X10F|XH11|XB10|XH50)
/* strict */
#define VERS_STRICT (VERS_HTML5|VERS_HTML40_STRICT)
/* all W3C defined document types */
#define VERS_ALL (VERS_HTML20|VERS_HTML32|VERS_FROM40|XH50|HT50)

View file

@ -1,2 +1,2 @@
5.1.37
5.1.38
2016.02.16