From 0c5550b06f086b2136a139ee2a75c5b692d1a80e Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Wed, 15 Mar 2017 17:36:05 -0400 Subject: [PATCH] I think the messages are where I want them to be. Will generate test cases for comparison. Also regen'd all pots and language headers. --- include/tidyenum.h | 2 +- localize/translations/language_en_gb.po | 7 ++++++- localize/translations/language_es.po | 7 ++++++- localize/translations/language_es_mx.po | 7 ++++++- localize/translations/language_fr.po | 7 ++++++- localize/translations/language_zh_cn.po | 7 ++++++- localize/translations/tidy.pot | 7 ++++++- src/language_en.h | 5 +++-- src/language_en_gb.h | 2 +- src/language_es.h | 2 +- src/language_es_mx.h | 2 +- src/language_fr.h | 2 +- src/language_zh_cn.h | 2 +- src/lexer.c | 12 +++++++++++- src/message.c | 6 +----- src/tags.c | 23 ++++++++++++----------- src/tags.h | 3 +++ 17 files changed, 72 insertions(+), 31 deletions(-) diff --git a/include/tidyenum.h b/include/tidyenum.h index 24f81c4..7efd971 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -908,7 +908,6 @@ typedef enum FN(PROPRIETARY_ELEMENT) \ FN(REPLACING_ELEMENT) \ FN(CUSTOM_TAG_DETECTED) \ - FN(CUSTOM_TAG_DETECTED_SETTING) \ FN(REPLACING_UNEX_ELEMENT) \ FN(SPACE_PRECEDING_XMLDECL) \ FN(SUSPECTED_MISSING_QUOTE) \ @@ -921,6 +920,7 @@ typedef enum FN(UNEXPECTED_ENDTAG_IN) \ FN(UNEXPECTED_ENDTAG) \ FN(UNKNOWN_ELEMENT) \ + FN(UNKNOWN_ELEMENT_LOOKS_CUSTOM) \ FN(USING_BR_INPLACE_OF) /* error codes used for attribute messages */ diff --git a/localize/translations/language_en_gb.po b/localize/translations/language_en_gb.po index 738e559..bfcbe2e 100644 --- a/localize/translations/language_en_gb.po +++ b/localize/translations/language_en_gb.po @@ -5,7 +5,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=n != 1;\n" "X-Generator: HTML Tidy poconvert.rb\n" "Project-Id-Version: \n" -"PO-Revision-Date: 2017-03-11 18:31:52\n" +"PO-Revision-Date: 2017-03-15 17:35:16\n" "Last-Translator: jderry\n" "Language-Team: \n" @@ -873,6 +873,11 @@ msgctxt "UNKNOWN_ELEMENT" msgid "%s is not recognized!" msgstr "" +#, c-format +msgctxt "UNKNOWN_ELEMENT_LOOKS_CUSTOM" +msgid "%s is not recognized! Did you mean to enable the custom-tags option?" +msgstr "" + #, c-format msgctxt "PREVIOUS_LOCATION" msgid "<%s> previously mentioned" diff --git a/localize/translations/language_es.po b/localize/translations/language_es.po index f50c560..7f403f0 100644 --- a/localize/translations/language_es.po +++ b/localize/translations/language_es.po @@ -5,7 +5,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=n != 1;\n" "X-Generator: HTML Tidy poconvert.rb\n" "Project-Id-Version: \n" -"PO-Revision-Date: 2017-03-11 18:31:52\n" +"PO-Revision-Date: 2017-03-15 17:35:16\n" "Last-Translator: jderry\n" "Language-Team: \n" @@ -869,6 +869,11 @@ msgctxt "UNKNOWN_ELEMENT" msgid "%s is not recognized!" msgstr "" +#, c-format +msgctxt "UNKNOWN_ELEMENT_LOOKS_CUSTOM" +msgid "%s is not recognized! Did you mean to enable the custom-tags option?" +msgstr "" + #, c-format msgctxt "PREVIOUS_LOCATION" msgid "<%s> previously mentioned" diff --git a/localize/translations/language_es_mx.po b/localize/translations/language_es_mx.po index e6c59f8..558496e 100644 --- a/localize/translations/language_es_mx.po +++ b/localize/translations/language_es_mx.po @@ -5,7 +5,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=n != 1;\n" "X-Generator: HTML Tidy poconvert.rb\n" "Project-Id-Version: \n" -"PO-Revision-Date: 2017-03-11 18:31:52\n" +"PO-Revision-Date: 2017-03-15 17:35:16\n" "Last-Translator: jderry\n" "Language-Team: \n" @@ -869,6 +869,11 @@ msgctxt "UNKNOWN_ELEMENT" msgid "%s is not recognized!" msgstr "" +#, c-format +msgctxt "UNKNOWN_ELEMENT_LOOKS_CUSTOM" +msgid "%s is not recognized! Did you mean to enable the custom-tags option?" +msgstr "" + #, c-format msgctxt "PREVIOUS_LOCATION" msgid "<%s> previously mentioned" diff --git a/localize/translations/language_fr.po b/localize/translations/language_fr.po index 9309f19..0c5f4d0 100644 --- a/localize/translations/language_fr.po +++ b/localize/translations/language_fr.po @@ -5,7 +5,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n > 1);\n" "X-Generator: HTML Tidy poconvert.rb\n" "Project-Id-Version: \n" -"PO-Revision-Date: 2017-03-11 18:31:52\n" +"PO-Revision-Date: 2017-03-15 17:35:16\n" "Last-Translator: jderry\n" "Language-Team: \n" @@ -1006,6 +1006,11 @@ msgctxt "UNKNOWN_ELEMENT" msgid "%s is not recognized!" msgstr "%s n'est pas reconnue !" +#, c-format +msgctxt "UNKNOWN_ELEMENT_LOOKS_CUSTOM" +msgid "%s is not recognized! Did you mean to enable the custom-tags option?" +msgstr "" + #, c-format msgctxt "PREVIOUS_LOCATION" msgid "<%s> previously mentioned" diff --git a/localize/translations/language_zh_cn.po b/localize/translations/language_zh_cn.po index dd377fa..63b043e 100644 --- a/localize/translations/language_zh_cn.po +++ b/localize/translations/language_zh_cn.po @@ -5,7 +5,7 @@ msgstr "" "Plural-Forms: nplurals=1; plural=0;\n" "X-Generator: HTML Tidy poconvert.rb\n" "Project-Id-Version: \n" -"PO-Revision-Date: 2017-03-11 18:31:52\n" +"PO-Revision-Date: 2017-03-15 17:35:16\n" "Last-Translator: jderry\n" "Language-Team: \n" @@ -863,6 +863,11 @@ msgctxt "UNKNOWN_ELEMENT" msgid "%s is not recognized!" msgstr "" +#, c-format +msgctxt "UNKNOWN_ELEMENT_LOOKS_CUSTOM" +msgid "%s is not recognized! Did you mean to enable the custom-tags option?" +msgstr "" + #, c-format msgctxt "PREVIOUS_LOCATION" msgid "<%s> previously mentioned" diff --git a/localize/translations/tidy.pot b/localize/translations/tidy.pot index 5b75e81..10696d2 100644 --- a/localize/translations/tidy.pot +++ b/localize/translations/tidy.pot @@ -5,7 +5,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=n != 1;\n" "X-Generator: HTML Tidy poconvert.rb\n" "Project-Id-Version: \n" -"POT-Creation-Date: 2017-03-11 18:31:52\n" +"POT-Creation-Date: 2017-03-15 17:35:16\n" "Last-Translator: jderry\n" "Language-Team: \n" @@ -865,6 +865,11 @@ msgctxt "UNKNOWN_ELEMENT" msgid "%s is not recognized!" msgstr "" +#, c-format +msgctxt "UNKNOWN_ELEMENT_LOOKS_CUSTOM" +msgid "%s is not recognized! Did you mean to enable the custom-tags option?" +msgstr "" + #, c-format msgctxt "PREVIOUS_LOCATION" msgid "<%s> previously mentioned" diff --git a/src/language_en.h b/src/language_en.h index 59cae7b..2b23455 100644 --- a/src/language_en.h +++ b/src/language_en.h @@ -386,7 +386,6 @@ static languageDefinition language_en = { whichPluralForm_en, { { TRIM_EMPTY_ELEMENT, 0, "trimming empty %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_SETTING, 0, "%s appears to be an autonomous custom tag; did you mean to set the custom-tags option?" }, /* Notice */ { TidyCustomBlocklevel, 0, "block level" }, { TidyCustomEmpty, 0, "empty" }, { TidyCustomInline, 0, "inline" }, @@ -437,7 +436,9 @@ static languageDefinition language_en = { whichPluralForm_en, { { SUSPECTED_MISSING_QUOTE, 0, "missing quote mark for attribute value" }, /* Error? (not really sometimes) */ { DUPLICATE_FRAMESET, 0, "repeated FRAMESET element" }, /* Error */ { UNKNOWN_ELEMENT, 0, "%s is not recognized!" }, /* Error */ - + { UNKNOWN_ELEMENT_LOOKS_CUSTOM, 0, "%s is not recognized! Did you mean to enable the custom-tags option?" }, /* Error */ + + /* Info */ { PREVIOUS_LOCATION, 0, "<%s> previously mentioned" }, /* Info */ diff --git a/src/language_en_gb.h b/src/language_en_gb.h index efd2d2d..46966ae 100644 --- a/src/language_en_gb.h +++ b/src/language_en_gb.h @@ -28,7 +28,7 @@ * * Orginating PO file metadata: * PO_LAST_TRANSLATOR=jderry - * PO_REVISION_DATE=2017-03-11 18:31:52 + * PO_REVISION_DATE=2017-03-15 17:35:16 */ #ifdef _MSC_VER diff --git a/src/language_es.h b/src/language_es.h index af42480..924ed89 100644 --- a/src/language_es.h +++ b/src/language_es.h @@ -28,7 +28,7 @@ * * Orginating PO file metadata: * PO_LAST_TRANSLATOR=jderry - * PO_REVISION_DATE=2017-03-11 18:31:52 + * PO_REVISION_DATE=2017-03-15 17:35:16 */ #ifdef _MSC_VER diff --git a/src/language_es_mx.h b/src/language_es_mx.h index be77669..d3ace4e 100644 --- a/src/language_es_mx.h +++ b/src/language_es_mx.h @@ -28,7 +28,7 @@ * * Orginating PO file metadata: * PO_LAST_TRANSLATOR=jderry - * PO_REVISION_DATE=2017-03-11 18:31:52 + * PO_REVISION_DATE=2017-03-15 17:35:16 */ #ifdef _MSC_VER diff --git a/src/language_fr.h b/src/language_fr.h index 6d8f4d9..3993dc4 100644 --- a/src/language_fr.h +++ b/src/language_fr.h @@ -28,7 +28,7 @@ * * Orginating PO file metadata: * PO_LAST_TRANSLATOR=jderry - * PO_REVISION_DATE=2017-03-11 18:31:52 + * PO_REVISION_DATE=2017-03-15 17:35:16 */ #ifdef _MSC_VER diff --git a/src/language_zh_cn.h b/src/language_zh_cn.h index 590a39f..e3579d8 100644 --- a/src/language_zh_cn.h +++ b/src/language_zh_cn.h @@ -28,7 +28,7 @@ * * Orginating PO file metadata: * PO_LAST_TRANSLATOR=jderry - * PO_REVISION_DATE=2017-03-11 18:31:52 + * PO_REVISION_DATE=2017-03-15 17:35:16 */ #ifdef _MSC_VER diff --git a/src/lexer.c b/src/lexer.c index efefe74..ea42eec 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -3000,7 +3000,17 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode ) if (lexer->token->tag == NULL) { if (mode != OtherNamespace) /* [i_a]2 only issue warning if NOT 'OtherNamespace', and tag null */ - TY_(ReportFatal)( doc, NULL, lexer->token, UNKNOWN_ELEMENT ); + { + /* Special case for HTML5 unknown tags: if it looks + like an autonomous custom tag, then emit a variation + of the standard message. We don't want to do this + for older HTML, because it's not truly supported + by the standard, although Tidy will allow it. */ + if ( (doc->lexer->doctype & VERS_HTML5) > 0 && TY_(elementIsAutonomousCustomFormat)( lexer->token->element ) ) + TY_(ReportFatal)( doc, NULL, lexer->token, UNKNOWN_ELEMENT_LOOKS_CUSTOM ); + else + TY_(ReportFatal)( doc, NULL, lexer->token, UNKNOWN_ELEMENT ); + } } else if ( !cfgBool(doc, TidyXmlTags) ) { diff --git a/src/message.c b/src/message.c index a5e17f7..794c079 100755 --- a/src/message.c +++ b/src/message.c @@ -232,11 +232,6 @@ void TY_(ReportNotice)(TidyDocImpl* doc, Node *element, Node *node, uint code) tagtype = tidyLocalizedString( cfg( doc, TidyUseCustomTags ) ); message = TY_(tidyMessageCreateWithNode)(doc, element, code, TidyInfo, elemdesc, tagtype ); break; - - case CUSTOM_TAG_DETECTED_SETTING: - message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyInfo, nodedesc ); - break; - } messageOut( message ); @@ -418,6 +413,7 @@ void TY_(ReportFatal)( TidyDocImpl* doc, Node *element, Node *node, uint code) break; case UNKNOWN_ELEMENT: + case UNKNOWN_ELEMENT_LOOKS_CUSTOM: TagToString(node, nodedesc, sizeof(nodedesc)); message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyError, nodedesc ); break; diff --git a/src/tags.c b/src/tags.c index 1c6819b..a58fe9d 100644 --- a/src/tags.c +++ b/src/tags.c @@ -586,13 +586,6 @@ Bool TY_(FindTag)( TidyDocImpl* doc, Node *node ) 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; } @@ -1056,14 +1049,14 @@ Bool nodeMatchCM( Node* node, uint contentModel ) #endif -Bool TY_(nodeIsAutonomousCustomFormat)( Node* node ) +Bool TY_(elementIsAutonomousCustomFormat)( ctmbstr element ) { - if ( node->element ) + if ( element ) { - const char *ptr = strchr(node->element, '-'); + const char *ptr = strchr(element, '-'); /* Tag must contain hyphen not in first character. */ - if ( ptr && (ptr - node->element > 0) ) + if ( ptr && (ptr - element > 0) ) { return yes; } @@ -1072,6 +1065,14 @@ Bool TY_(nodeIsAutonomousCustomFormat)( Node* node ) return no; } +Bool TY_(nodeIsAutonomousCustomFormat)( Node* node ) +{ + if ( node->element ) + return TY_(elementIsAutonomousCustomFormat)( node->element ); + + return no; +} + Bool TY_(nodeIsAutonomousCustomTag)( TidyDocImpl* doc, Node* node ) { return TY_(nodeIsAutonomousCustomFormat)( node ) diff --git a/src/tags.h b/src/tags.h index 0b962c6..ba746ed 100644 --- a/src/tags.h +++ b/src/tags.h @@ -134,6 +134,9 @@ Bool nodeMatchCM( Node* node, uint contentModel ); #endif +/* True if the element looks like it's an autonomous custom element tag. */ +Bool TY_(elementIsAutonomousCustomFormat)( ctmbstr element ); + /* True if the node looks like it's an autonomous custom element tag. */ Bool TY_(nodeIsAutonomousCustomFormat)( Node* node );