Add TY_(nodeIsAutonomousCustomTag), so we can use it elsewhere.

This commit is contained in:
Jim Derry 2017-03-14 15:44:46 -04:00
parent 8273491e16
commit ed5a1d84ea
2 changed files with 42 additions and 24 deletions

View file

@ -546,9 +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 );
const Dict *np = NULL; const Dict *np = NULL;
if ( cfgBool(doc, TidyXmlTags) ) if ( cfgBool(doc, TidyXmlTags) )
{ {
node->tag = doc->tags.xml_tags; node->tag = doc->tags.xml_tags;
@ -562,30 +561,25 @@ Bool TY_(FindTag)( TidyDocImpl* doc, Node *node )
} }
/* Add anonymous custom tag */ /* Add anonymous custom tag */
if ( node->element && configtype != TidyCustomNo ) if ( TY_(nodeIsAutonomousCustomTag)( doc, node) )
{ {
const char *ptr = strchr(node->element, '-'); TidyUseCustomTagsState configtype = cfg( doc, TidyUseCustomTags );
UserTagType type;
/* Tag must contain hyphen not in first character. */ if ( configtype == TidyCustomEmpty )
if ( ptr && (ptr - node->element > 0) ) type = tagtype_empty;
{ else if ( configtype == TidyCustomInline )
UserTagType type; type = tagtype_inline;
else if ( configtype == TidyCustomPre )
if ( configtype == TidyCustomEmpty ) type = tagtype_pre;
type = tagtype_empty; else
else if ( configtype == TidyCustomInline ) type = tagtype_block;
type = tagtype_inline;
else if ( configtype == TidyCustomPre ) TY_(DeclareUserTag)( doc, TidyCustomTags, type, node->element );
type = tagtype_pre; node->tag = tagsLookup(doc, &doc->tags, node->element);
else TY_(ReportNotice)(doc, node, node, CUSTOM_TAG_DETECTED);
type = tagtype_block;
return yes;
TY_(DeclareUserTag)( doc, TidyCustomTags, type, node->element );
node->tag = tagsLookup(doc, &doc->tags, node->element);
TY_(ReportNotice)(doc, node, node, CUSTOM_TAG_DETECTED);
return yes;
}
} }
return no; return no;
@ -1049,6 +1043,25 @@ Bool nodeMatchCM( Node* node, uint contentModel )
} }
#endif #endif
/* True if the node looks like it's an autonomous custom element tag.
*/
Bool TY_(nodeIsAutonomousCustomTag)( TidyDocImpl* doc, Node* node )
{
if ( node->element && cfg( doc, TidyUseCustomTags ) != TidyCustomNo )
{
const char *ptr = strchr(node->element, '-');
/* Tag must contain hyphen not in first character. */
if ( ptr && (ptr - node->element > 0) )
{
return yes;
}
}
return no;
}
/* 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 )

View file

@ -133,6 +133,11 @@ Bool TY_(nodeHasText)( TidyDocImpl* doc, Node* node );
Bool nodeMatchCM( Node* node, uint contentModel ); Bool nodeMatchCM( Node* node, uint contentModel );
#endif #endif
/* True if the node looks like it's an autonomous custom element tag.
*/
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 );