WIP; messaging much more logical, except @todo noted.
This commit is contained in:
parent
66ade9def4
commit
5606f32f13
|
@ -908,6 +908,7 @@ typedef enum
|
||||||
FN(PROPRIETARY_ELEMENT) \
|
FN(PROPRIETARY_ELEMENT) \
|
||||||
FN(REPLACING_ELEMENT) \
|
FN(REPLACING_ELEMENT) \
|
||||||
FN(CUSTOM_TAG_DETECTED) \
|
FN(CUSTOM_TAG_DETECTED) \
|
||||||
|
FN(CUSTOM_TAG_DETECTED_SETTING) \
|
||||||
FN(REPLACING_UNEX_ELEMENT) \
|
FN(REPLACING_UNEX_ELEMENT) \
|
||||||
FN(SPACE_PRECEDING_XMLDECL) \
|
FN(SPACE_PRECEDING_XMLDECL) \
|
||||||
FN(SUSPECTED_MISSING_QUOTE) \
|
FN(SUSPECTED_MISSING_QUOTE) \
|
||||||
|
|
|
@ -386,6 +386,7 @@ static languageDefinition language_en = { whichPluralForm_en, {
|
||||||
{ TRIM_EMPTY_ELEMENT, 0, "trimming empty %s" }, /* Notice */
|
{ TRIM_EMPTY_ELEMENT, 0, "trimming empty %s" }, /* Notice */
|
||||||
{ REPLACING_ELEMENT, 0, "replacing %s with %s" }, /* Notice */
|
{ REPLACING_ELEMENT, 0, "replacing %s with %s" }, /* Notice */
|
||||||
{ CUSTOM_TAG_DETECTED, 0, "detected autonomous custom tag %s; will treat as %s" }, /* Notice */
|
{ CUSTOM_TAG_DETECTED, 0, "detected autonomous custom tag %s; will treat as %s" }, /* Notice */
|
||||||
|
{ CUSTOM_TAG_DETECTED_SETTING, 0, "%s appears to be an autonomous custom tag; did you mean to set the custom-tags option?" }, /* Notice */
|
||||||
{ TidyCustomBlocklevel, 0, "block level" },
|
{ TidyCustomBlocklevel, 0, "block level" },
|
||||||
{ TidyCustomEmpty, 0, "empty" },
|
{ TidyCustomEmpty, 0, "empty" },
|
||||||
{ TidyCustomInline, 0, "inline" },
|
{ TidyCustomInline, 0, "inline" },
|
||||||
|
|
|
@ -232,6 +232,11 @@ void TY_(ReportNotice)(TidyDocImpl* doc, Node *element, Node *node, uint code)
|
||||||
tagtype = tidyLocalizedString( cfg( doc, TidyUseCustomTags ) );
|
tagtype = tidyLocalizedString( cfg( doc, TidyUseCustomTags ) );
|
||||||
message = TY_(tidyMessageCreateWithNode)(doc, element, code, TidyInfo, elemdesc, tagtype );
|
message = TY_(tidyMessageCreateWithNode)(doc, element, code, TidyInfo, elemdesc, tagtype );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CUSTOM_TAG_DETECTED_SETTING:
|
||||||
|
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyInfo, nodedesc );
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
messageOut( message );
|
messageOut( message );
|
||||||
|
|
48
src/tags.c
48
src/tags.c
|
@ -546,6 +546,8 @@ void show_have_html5(void)
|
||||||
/* public interface for finding tag by name */
|
/* public interface for finding tag by name */
|
||||||
Bool TY_(FindTag)( TidyDocImpl* doc, Node *node )
|
Bool TY_(FindTag)( TidyDocImpl* doc, Node *node )
|
||||||
{
|
{
|
||||||
|
TidyUseCustomTagsState configtype = cfg( doc, TidyUseCustomTags );
|
||||||
|
Bool htmlIs5 = (doc->lexer->doctype & VERS_HTML5) > 0;
|
||||||
const Dict *np = NULL;
|
const Dict *np = NULL;
|
||||||
|
|
||||||
if ( cfgBool(doc, TidyXmlTags) )
|
if ( cfgBool(doc, TidyXmlTags) )
|
||||||
|
@ -560,12 +562,12 @@ Bool TY_(FindTag)( TidyDocImpl* doc, Node *node )
|
||||||
return yes;
|
return yes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add anonymous custom tag */
|
/* Add autonomous custom tag. This can be done in both HTML5 mode and
|
||||||
|
earlier, although if it's earlier we will complain about it elsewhere. */
|
||||||
if ( TY_(nodeIsAutonomousCustomTag)( doc, node) )
|
if ( TY_(nodeIsAutonomousCustomTag)( doc, node) )
|
||||||
{
|
{
|
||||||
UserTagType type;
|
UserTagType type;
|
||||||
TidyUseCustomTagsState configtype = cfg( doc, TidyUseCustomTags );
|
|
||||||
|
|
||||||
if ( configtype == TidyCustomEmpty )
|
if ( configtype == TidyCustomEmpty )
|
||||||
type = tagtype_empty;
|
type = tagtype_empty;
|
||||||
else if ( configtype == TidyCustomInline )
|
else if ( configtype == TidyCustomInline )
|
||||||
|
@ -578,19 +580,19 @@ Bool TY_(FindTag)( TidyDocImpl* doc, Node *node )
|
||||||
TY_(DeclareUserTag)( doc, TidyCustomTags, type, node->element );
|
TY_(DeclareUserTag)( doc, TidyCustomTags, type, node->element );
|
||||||
node->tag = tagsLookup(doc, &doc->tags, node->element);
|
node->tag = tagsLookup(doc, &doc->tags, node->element);
|
||||||
|
|
||||||
if ( (doc->lexer->doctype & VERS_HTML5) )
|
/* Output a message the first time we encounter an autonomous custom
|
||||||
{
|
tag. This applies despite the HTML5 mode. */
|
||||||
TY_(ReportNotice)(doc, node, node, CUSTOM_TAG_DETECTED);
|
TY_(ReportNotice)(doc, node, node, CUSTOM_TAG_DETECTED);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* TODO: not sure whether to include this here, or let it
|
|
||||||
happen where it already happens; still need to suppress elsewhere */
|
|
||||||
TY_(ReportError)(doc, NULL, node, PROPRIETARY_ELEMENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
return yes;
|
return yes;
|
||||||
}
|
}
|
||||||
|
else if ( TY_(nodeIsAutonomousCustomFormat)( node ) && htmlIs5 )
|
||||||
|
{
|
||||||
|
/* It looks like a custom tag, we're in HTML5, but custom-tags is
|
||||||
|
off, so warn the user. TODO: handle in the lexer so we don't
|
||||||
|
repeat this over and over again.*/
|
||||||
|
TY_(ReportNotice)(doc, node, node, CUSTOM_TAG_DETECTED_SETTING);
|
||||||
|
}
|
||||||
|
|
||||||
return no;
|
return no;
|
||||||
}
|
}
|
||||||
|
@ -1054,24 +1056,30 @@ Bool nodeMatchCM( Node* node, uint contentModel )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* True if the node looks like it's an autonomous custom element tag.
|
Bool TY_(nodeIsAutonomousCustomFormat)( Node* node )
|
||||||
*/
|
|
||||||
Bool TY_(nodeIsAutonomousCustomTag)( TidyDocImpl* doc, Node* node )
|
|
||||||
{
|
{
|
||||||
if ( node->element && cfg( doc, TidyUseCustomTags ) != TidyCustomNo )
|
if ( node->element )
|
||||||
{
|
{
|
||||||
const char *ptr = strchr(node->element, '-');
|
const char *ptr = strchr(node->element, '-');
|
||||||
|
|
||||||
/* Tag must contain hyphen not in first character. */
|
/* Tag must contain hyphen not in first character. */
|
||||||
if ( ptr && (ptr - node->element > 0) )
|
if ( ptr && (ptr - node->element > 0) )
|
||||||
{
|
{
|
||||||
return yes;
|
return yes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return no;
|
return no;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Bool TY_(nodeIsAutonomousCustomTag)( TidyDocImpl* doc, Node* node )
|
||||||
|
{
|
||||||
|
return TY_(nodeIsAutonomousCustomFormat)( node )
|
||||||
|
&& ( cfg( doc, TidyUseCustomTags ) != TidyCustomNo );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* True if any of the bits requested are set.
|
/* True if any of the bits requested are set.
|
||||||
*/
|
*/
|
||||||
Bool TY_(nodeHasCM)( Node* node, uint contentModel )
|
Bool TY_(nodeHasCM)( Node* node, uint contentModel )
|
||||||
|
|
|
@ -134,10 +134,16 @@ Bool nodeMatchCM( Node* node, uint contentModel );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* True if the node looks like it's an autonomous custom element tag.
|
/* True if the node looks like it's an autonomous custom element tag. */
|
||||||
|
Bool TY_(nodeIsAutonomousCustomFormat)( Node* node );
|
||||||
|
|
||||||
|
/* True if the node looks like it's an autonomous custom element tag, and
|
||||||
|
TidyCustomTags is not disabled, and we're in HTML5 mode, which are all
|
||||||
|
requirements for valid autonomous custom tags.
|
||||||
*/
|
*/
|
||||||
Bool TY_(nodeIsAutonomousCustomTag)( TidyDocImpl* doc, Node* node );
|
Bool TY_(nodeIsAutonomousCustomTag)( TidyDocImpl* doc, Node* node );
|
||||||
|
|
||||||
|
|
||||||
/* True if any of the bits requested are set.
|
/* True if any of the bits requested are set.
|
||||||
*/
|
*/
|
||||||
Bool TY_(nodeHasCM)( Node* node, uint contentModel );
|
Bool TY_(nodeHasCM)( Node* node, uint contentModel );
|
||||||
|
|
|
@ -1747,6 +1747,8 @@ void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node )
|
||||||
AttVal *next_attr, *attval;
|
AttVal *next_attr, *attval;
|
||||||
Bool attrIsProprietary = no;
|
Bool attrIsProprietary = no;
|
||||||
Bool attrIsMismatched = yes;
|
Bool attrIsMismatched = yes;
|
||||||
|
Bool tagLooksCustom = no;
|
||||||
|
Bool htmlIs5 = (doc->lexer->doctype & VERS_HTML5) > 0;
|
||||||
|
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
|
@ -1767,7 +1769,20 @@ void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node )
|
||||||
if ( !cfgBool(doc, TidyMakeClean) ||
|
if ( !cfgBool(doc, TidyMakeClean) ||
|
||||||
( !nodeIsNOBR(node) && !nodeIsWBR(node) ) )
|
( !nodeIsNOBR(node) && !nodeIsWBR(node) ) )
|
||||||
{
|
{
|
||||||
TY_(ReportError)(doc, NULL, node, PROPRIETARY_ELEMENT );
|
/* It looks custom, despite whether it's a known tag. */
|
||||||
|
tagLooksCustom = TY_(nodeIsAutonomousCustomFormat)( node );
|
||||||
|
|
||||||
|
/* If we're in HTML5 mode and the tag does not look
|
||||||
|
like a valid custom tag, then issue a warning.
|
||||||
|
Appearance is good enough because invalid tags have
|
||||||
|
been dropped. Also, if we're not in HTML5 mode, then
|
||||||
|
then everything that reaches here gets the warning.
|
||||||
|
Everything else can be ignored. */
|
||||||
|
|
||||||
|
if ( (htmlIs5 && !tagLooksCustom) || !htmlIs5 )
|
||||||
|
{
|
||||||
|
TY_(ReportError)(doc, NULL, node, PROPRIETARY_ELEMENT );
|
||||||
|
}
|
||||||
|
|
||||||
if ( nodeIsLAYER(node) )
|
if ( nodeIsLAYER(node) )
|
||||||
doc->badLayout |= USING_LAYER;
|
doc->badLayout |= USING_LAYER;
|
||||||
|
|
Loading…
Reference in a new issue