From ed5a1d84ea56d2cf6fc8c9ab5f3b3f52f18de387 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Tue, 14 Mar 2017 15:44:46 -0400 Subject: [PATCH] Add TY_(nodeIsAutonomousCustomTag), so we can use it elsewhere. --- src/tags.c | 61 +++++++++++++++++++++++++++++++++--------------------- src/tags.h | 5 +++++ 2 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/tags.c b/src/tags.c index 75ae5a9..2efbf5b 100644 --- a/src/tags.c +++ b/src/tags.c @@ -546,9 +546,8 @@ void show_have_html5(void) /* public interface for finding tag by name */ Bool TY_(FindTag)( TidyDocImpl* doc, Node *node ) { - TidyUseCustomTagsState configtype = cfg( doc, TidyUseCustomTags ); - const Dict *np = NULL; + if ( cfgBool(doc, TidyXmlTags) ) { node->tag = doc->tags.xml_tags; @@ -562,30 +561,25 @@ Bool TY_(FindTag)( TidyDocImpl* doc, Node *node ) } /* 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 ( ptr && (ptr - node->element > 0) ) - { - UserTagType type; - - if ( configtype == TidyCustomEmpty ) - type = tagtype_empty; - else if ( configtype == TidyCustomInline ) - type = tagtype_inline; - else if ( configtype == TidyCustomPre ) - type = tagtype_pre; - else - type = tagtype_block; - - 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; - } + if ( configtype == TidyCustomEmpty ) + type = tagtype_empty; + else if ( configtype == TidyCustomInline ) + type = tagtype_inline; + else if ( configtype == TidyCustomPre ) + type = tagtype_pre; + else + type = tagtype_block; + + 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; @@ -1049,6 +1043,25 @@ Bool nodeMatchCM( Node* node, uint contentModel ) } #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. */ Bool TY_(nodeHasCM)( Node* node, uint contentModel ) diff --git a/src/tags.h b/src/tags.h index de75809..988ceca 100644 --- a/src/tags.h +++ b/src/tags.h @@ -133,6 +133,11 @@ Bool TY_(nodeHasText)( TidyDocImpl* doc, Node* node ); Bool nodeMatchCM( Node* node, uint contentModel ); #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. */ Bool TY_(nodeHasCM)( Node* node, uint contentModel );