Begin migration towards "one output function to rule them all." Consolidated
the basic reporting functions that share the same signature. This also resulted in eliminating a string, and adding a new string to disambiguate between errors and warnings.
This commit is contained in:
parent
7badd93417
commit
e5eb09198d
|
@ -260,7 +260,6 @@ extern "C" {
|
|||
FN(BAD_SURROGATE_TAIL) \
|
||||
/* ReportWarning */ \
|
||||
FN(BAD_SUMMARY_HTML5) \
|
||||
FN(COERCE_TO_ENDTAG_WARN) \
|
||||
FN(NESTED_EMPHASIS) \
|
||||
FN(NESTED_QUOTATION) \
|
||||
FN(OBSOLETE_ELEMENT) \
|
||||
|
@ -271,6 +270,7 @@ extern "C" {
|
|||
FN(ELEMENT_NOT_EMPTY) \
|
||||
FN(UNEXPECTED_END_OF_FILE) \
|
||||
FN(UNEXPECTED_ENDTAG) \
|
||||
FN(UNEXPECTED_ENDTAG_ERR) \
|
||||
FN(MOVED_STYLE_TO_HEAD) \
|
||||
FN(FOUND_STYLE_IN_BODY)
|
||||
|
||||
|
|
|
@ -1986,7 +1986,7 @@ void TY_(CleanWord2000)( TidyDocImpl* doc, Node *node)
|
|||
* meaning this result would not ordinarily be displayed.
|
||||
*/
|
||||
Node* next;
|
||||
TY_(ReportError)(doc, NULL, node, PROPRIETARY_ELEMENT);
|
||||
TY_(ReportNotice)(doc, NULL, node, PROPRIETARY_ELEMENT);
|
||||
DiscardContainer( doc, node, &next );
|
||||
node = next;
|
||||
continue;
|
||||
|
|
|
@ -1891,17 +1891,17 @@ static languageDefinition language_en = { whichPluralForm_en, {
|
|||
{ BAD_SURROGATE_TAIL, 0, "Leading (High) surrogate pair U+%04X, with no trailing (Low) entity, replaced with U+FFFD." }, /* ReportSurrogateError */
|
||||
|
||||
{ BAD_SUMMARY_HTML5, 0, "The summary attribute on the %s element is obsolete in HTML5" }, /* ReportWarning */
|
||||
{ COERCE_TO_ENDTAG_WARN, 0, "<%s> is probably intended as </%s>" }, /* ReportWarning */
|
||||
{ NESTED_EMPHASIS, 0, "nested emphasis %s" }, /* ReportWarning */
|
||||
{ NESTED_QUOTATION, 0, "nested q elements, possible typo." }, /* ReportWarning */
|
||||
{ OBSOLETE_ELEMENT, 0, "replacing obsolete element %s with %s" }, /* ReportWarning */
|
||||
{ REMOVED_HTML5, 0, "%s element removed from HTML5" }, /* ReportWarning */
|
||||
{ XML_DECLARATION_DETECTED, 0, "An XML declaration was detected. Did you mean to use input-xml?" }, /* ReportWarning */
|
||||
|
||||
{ COERCE_TO_ENDTAG, 0, "<%s> is probably intended as </%s>" }, /* ReportError, ReportWarning */
|
||||
{ COERCE_TO_ENDTAG, 0, "<%s> is probably intended as </%s>" }, /* ReportWarning */
|
||||
{ ELEMENT_NOT_EMPTY, 0, "%s element not empty or not closed" }, /* ReportError, ReportAttrError */
|
||||
{ UNEXPECTED_END_OF_FILE, 0, "unexpected end of file %s" }, /* ReportError, ReportAttrError */
|
||||
{ UNEXPECTED_ENDTAG, 0, "unexpected </%s>" }, /* ReportError, ReportFatal */
|
||||
{ UNEXPECTED_ENDTAG, 0, "unexpected </%s>" }, /* ReportWarning */
|
||||
{ UNEXPECTED_ENDTAG_ERR, 0, "unexpected </%s>" }, /* ReportError */
|
||||
{ MOVED_STYLE_TO_HEAD, 0, "moved <style> tag to <head>! fix-style-tags: no to avoid." }, /* ReportWarning */
|
||||
{ FOUND_STYLE_IN_BODY, 0, "found <style> tag in <body>! fix-style-tags: yes to move." }, /* ReportWarning */
|
||||
|
||||
|
|
|
@ -874,7 +874,6 @@ static languageDefinition language_fr = { whichPluralForm_fr, {
|
|||
"+FFFD."
|
||||
},
|
||||
{ BAD_SUMMARY_HTML5, 0, "L'attribut summary sur l'élément %s est obsolète avec HTML5" },
|
||||
{ COERCE_TO_ENDTAG_WARN, 0, "<%s> est probablement destiné à </%s>" },
|
||||
{ NESTED_EMPHASIS, 0, "accentuation imbriquée %s" },
|
||||
{ NESTED_QUOTATION, 0, "éléments \"q\" imbriqués, erreur typographique possible" },
|
||||
{ OBSOLETE_ELEMENT, 0, "remplacement de l'élément obsolète %s par %s" },
|
||||
|
@ -884,6 +883,7 @@ static languageDefinition language_fr = { whichPluralForm_fr, {
|
|||
{ ELEMENT_NOT_EMPTY, 0, "%s élément non vide ou non fermé" },
|
||||
{ UNEXPECTED_END_OF_FILE, 0, "fin de fichier inattendue %s" },
|
||||
{ UNEXPECTED_ENDTAG, 0, "</%s> inattendu" },
|
||||
{ UNEXPECTED_ENDTAG_ERR, 0, "</%s> inattendu" },
|
||||
|
||||
#if SUPPORT_ACCESSIBILITY_CHECKS
|
||||
{ IMG_MISSING_ALT, 0, "[1.1.1.1]: <img> texte manquant 'alt'." },
|
||||
|
|
22
src/lexer.c
22
src/lexer.c
|
@ -2454,7 +2454,7 @@ static Node *GetCDATA( TidyDocImpl* doc, Node *container )
|
|||
if ((TY_(IsJavaScript)(container)) && cfgBool(doc, TidyEscapeScripts))
|
||||
{
|
||||
/* Issue #281 - only warn if adding the escape! */
|
||||
TY_(ReportError)(doc, NULL, NULL, BAD_CDATA_CONTENT);
|
||||
TY_(ReportNotice)(doc, NULL, NULL, BAD_CDATA_CONTENT);
|
||||
|
||||
for (i = lexer->lexsize; i > start-1; --i)
|
||||
lexer->lexbuf[i] = lexer->lexbuf[i-1];
|
||||
|
@ -2472,7 +2472,7 @@ static Node *GetCDATA( TidyDocImpl* doc, Node *container )
|
|||
lexer->txtend = lexer->lexsize;
|
||||
|
||||
if (c == EndOfStream)
|
||||
TY_(ReportError)(doc, container, NULL, MISSING_ENDTAG_FOR );
|
||||
TY_(ReportNotice)(doc, container, NULL, MISSING_ENDTAG_FOR );
|
||||
|
||||
/* this was disabled for some reason... */
|
||||
#if 0
|
||||
|
@ -2764,7 +2764,7 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode )
|
|||
continue;
|
||||
}
|
||||
|
||||
TY_(ReportError)(doc, NULL, NULL, MALFORMED_COMMENT );
|
||||
TY_(ReportNotice)(doc, NULL, NULL, MALFORMED_COMMENT );
|
||||
}
|
||||
else if (c == 'd' || c == 'D')
|
||||
{
|
||||
|
@ -3013,9 +3013,9 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode )
|
|||
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 );
|
||||
TY_(ReportNotice)( doc, NULL, lexer->token, UNKNOWN_ELEMENT_LOOKS_CUSTOM );
|
||||
else
|
||||
TY_(ReportFatal)( doc, NULL, lexer->token, UNKNOWN_ELEMENT );
|
||||
TY_(ReportNotice)( doc, NULL, lexer->token, UNKNOWN_ELEMENT );
|
||||
}
|
||||
}
|
||||
else if ( !cfgBool(doc, TidyXmlTags) )
|
||||
|
@ -3048,7 +3048,7 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode )
|
|||
if (c == '>')
|
||||
{
|
||||
if (badcomment)
|
||||
TY_(ReportError)(doc, NULL, NULL, MALFORMED_COMMENT );
|
||||
TY_(ReportNotice)(doc, NULL, NULL, MALFORMED_COMMENT );
|
||||
|
||||
/* do not store closing -- in lexbuf */
|
||||
lexer->lexsize -= 2;
|
||||
|
@ -3163,7 +3163,7 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode )
|
|||
|
||||
if (c == EndOfStream)
|
||||
{
|
||||
TY_(ReportError)(doc, NULL, NULL, UNEXPECTED_END_OF_FILE );
|
||||
TY_(ReportNotice)(doc, NULL, NULL, UNEXPECTED_END_OF_FILE );
|
||||
TY_(UngetChar)(c, doc->docIn);
|
||||
continue;
|
||||
}
|
||||
|
@ -3474,7 +3474,7 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode )
|
|||
else if (lexer->state == LEX_COMMENT) /* comment */
|
||||
{
|
||||
if (c == EndOfStream)
|
||||
TY_(ReportError)(doc, NULL, NULL, MALFORMED_COMMENT );
|
||||
TY_(ReportNotice)(doc, NULL, NULL, MALFORMED_COMMENT );
|
||||
|
||||
lexer->txtend = lexer->lexsize;
|
||||
lexer->lexbuf[lexer->lexsize] = '\0';
|
||||
|
@ -4111,7 +4111,7 @@ static tmbstr ParseValue( TidyDocImpl* doc, ctmbstr name,
|
|||
!(TY_(IsUrl)(doc, name) && TY_(tmbstrncmp)(lexer->lexbuf+start, "javascript:", 11) == 0) &&
|
||||
!(TY_(tmbstrncmp)(lexer->lexbuf+start, "<xml ", 5) == 0)
|
||||
)
|
||||
TY_(ReportFatal)( doc, NULL, NULL, SUSPECTED_MISSING_QUOTE );
|
||||
TY_(ReportNotice)( doc, NULL, NULL, SUSPECTED_MISSING_QUOTE );
|
||||
}
|
||||
|
||||
len = lexer->lexsize - start;
|
||||
|
@ -4383,7 +4383,7 @@ static Node *ParseDocTypeDecl(TidyDocImpl* doc)
|
|||
|
||||
if (!node->element || !IsValidXMLElemName(node->element))
|
||||
{
|
||||
TY_(ReportError)(doc, NULL, NULL, MALFORMED_DOCTYPE);
|
||||
TY_(ReportNotice)(doc, NULL, NULL, MALFORMED_DOCTYPE);
|
||||
TY_(FreeNode)(doc, node);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -4469,7 +4469,7 @@ static Node *ParseDocTypeDecl(TidyDocImpl* doc)
|
|||
}
|
||||
|
||||
/* document type declaration not finished */
|
||||
TY_(ReportError)(doc, NULL, NULL, MALFORMED_DOCTYPE);
|
||||
TY_(ReportNotice)(doc, NULL, NULL, MALFORMED_DOCTYPE);
|
||||
TY_(FreeNode)(doc, node);
|
||||
return NULL;
|
||||
}
|
||||
|
|
248
src/message.c
248
src/message.c
|
@ -209,18 +209,56 @@ static void messageOut( TidyMessageImpl *message )
|
|||
void TY_(ReportNotice)(TidyDocImpl* doc, Node *element, Node *node, uint code)
|
||||
{
|
||||
TidyMessageImpl *message = NULL;
|
||||
TidyMessageImpl *message2 = NULL; /* extra, when TidyShowWarnings */
|
||||
Node* rpt = ( element ? element : node );
|
||||
char nodedesc[256] = { 0 };
|
||||
char elemdesc[256] = { 0 };
|
||||
uint versionEmitted, declared, version;
|
||||
ctmbstr extra_string = NULL;
|
||||
ctmbstr tagtype;
|
||||
|
||||
TagToString(node, nodedesc, sizeof(nodedesc));
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case INSERTING_TAG:
|
||||
case MISSING_STARTTAG:
|
||||
case TOO_MANY_ELEMENTS:
|
||||
case UNEXPECTED_ENDTAG:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyWarning, node->element );
|
||||
break;
|
||||
|
||||
case CANT_BE_NESTED:
|
||||
case NOFRAMES_CONTENT:
|
||||
case PROPRIETARY_ELEMENT:
|
||||
case UNESCAPED_ELEMENT:
|
||||
case USING_BR_INPLACE_OF:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyWarning, nodedesc );
|
||||
break;
|
||||
|
||||
case ELEMENT_NOT_EMPTY:
|
||||
case FOUND_STYLE_IN_BODY:
|
||||
case ILLEGAL_NESTING:
|
||||
case MOVED_STYLE_TO_HEAD:
|
||||
case TRIM_EMPTY_ELEMENT:
|
||||
TagToString(element, elemdesc, sizeof(nodedesc));
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, element, code, TidyWarning, elemdesc );
|
||||
case UNEXPECTED_END_OF_FILE:
|
||||
TagToString(element, elemdesc, sizeof(elemdesc));
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, element, code, TidyWarning, elemdesc);
|
||||
break;
|
||||
|
||||
case BAD_CDATA_CONTENT:
|
||||
case BAD_COMMENT_CHARS:
|
||||
case BAD_XML_COMMENT:
|
||||
case CONTENT_AFTER_BODY:
|
||||
case DOCTYPE_AFTER_TAGS:
|
||||
case DTYPE_NOT_UPPER_CASE:
|
||||
case INCONSISTENT_NAMESPACE:
|
||||
case INCONSISTENT_VERSION:
|
||||
case MALFORMED_COMMENT:
|
||||
case MALFORMED_DOCTYPE:
|
||||
case MISSING_TITLE_ELEMENT:
|
||||
case NESTED_QUOTATION:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning );
|
||||
break;
|
||||
|
||||
case REPLACING_ELEMENT:
|
||||
|
@ -228,6 +266,48 @@ void TY_(ReportNotice)(TidyDocImpl* doc, Node *element, Node *node, uint code)
|
|||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, elemdesc, nodedesc );
|
||||
break;
|
||||
|
||||
case OBSOLETE_ELEMENT:
|
||||
case REPLACING_UNEX_ELEMENT:
|
||||
TagToString(element, elemdesc, sizeof(elemdesc));
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, elemdesc, nodedesc );
|
||||
break;
|
||||
|
||||
case MISSING_ENDTAG_FOR:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, element->element );
|
||||
break;
|
||||
|
||||
case MISSING_ENDTAG_BEFORE:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, element->element, nodedesc );
|
||||
break;
|
||||
|
||||
case BAD_SUMMARY_HTML5:
|
||||
case NESTED_EMPHASIS:
|
||||
case REMOVED_HTML5:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, nodedesc );
|
||||
break;
|
||||
|
||||
case COERCE_TO_ENDTAG:
|
||||
case NON_MATCHING_ENDTAG:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, node->element, node->element );
|
||||
break;
|
||||
|
||||
case ENCODING_IO_CONFLICT:
|
||||
case MISSING_DOCTYPE:
|
||||
case SPACE_PRECEDING_XMLDECL:
|
||||
case XML_DECLARATION_DETECTED:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyWarning );
|
||||
break;
|
||||
|
||||
case ELEMENT_VERS_MISMATCH_WARN:
|
||||
versionEmitted = doc->lexer->versionEmitted;
|
||||
declared = doc->lexer->doctype;
|
||||
version = versionEmitted == 0 ? declared : versionEmitted;
|
||||
extra_string = TY_(HTMLVersionNameFromCode)(version, 0);
|
||||
if (!extra_string)
|
||||
extra_string = tidyLocalizedString(STRING_HTML_PROPRIETARY);
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyWarning, nodedesc, extra_string );
|
||||
break;
|
||||
|
||||
case CUSTOM_TAG_DETECTED:
|
||||
TagToString(element, elemdesc, sizeof(elemdesc));
|
||||
|
||||
|
@ -249,92 +329,6 @@ void TY_(ReportNotice)(TidyDocImpl* doc, Node *element, Node *node, uint code)
|
|||
}
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, element, code, TidyInfo, elemdesc, tagtype );
|
||||
break;
|
||||
case MOVED_STYLE_TO_HEAD:
|
||||
case FOUND_STYLE_IN_BODY:
|
||||
TagToString(element, elemdesc, sizeof(elemdesc));
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, element, code, TidyWarning, elemdesc);
|
||||
break;
|
||||
}
|
||||
|
||||
messageOut( message );
|
||||
}
|
||||
|
||||
|
||||
void TY_(ReportWarning)(TidyDocImpl* doc, Node *element, Node *node, uint code)
|
||||
{
|
||||
TidyMessageImpl *message = NULL;
|
||||
Node* rpt = (element ? element : node);
|
||||
char nodedesc[256] = { 0 };
|
||||
char elemdesc[256] = { 0 };
|
||||
|
||||
TagToString(node, nodedesc, sizeof(nodedesc));
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case NESTED_QUOTATION:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning );
|
||||
break;
|
||||
|
||||
case OBSOLETE_ELEMENT:
|
||||
TagToString(element, elemdesc, sizeof(elemdesc));
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, elemdesc, nodedesc );
|
||||
break;
|
||||
|
||||
case NESTED_EMPHASIS:
|
||||
case REMOVED_HTML5:
|
||||
case BAD_SUMMARY_HTML5:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, nodedesc );
|
||||
break;
|
||||
case COERCE_TO_ENDTAG_WARN:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, node->element, node->element );
|
||||
break;
|
||||
case XML_DECLARATION_DETECTED:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyWarning );
|
||||
break;
|
||||
}
|
||||
|
||||
messageOut( message );
|
||||
}
|
||||
|
||||
|
||||
void TY_(ReportError)(TidyDocImpl* doc, Node *element, Node *node, uint code)
|
||||
{
|
||||
TidyMessageImpl *message = NULL;
|
||||
TidyMessageImpl *message2 = NULL; /* extra, when TidyShowWarnings */
|
||||
char nodedesc[ 256 ] = {0};
|
||||
char elemdesc[ 256 ] = {0};
|
||||
Node* rpt = ( element ? element : node );
|
||||
uint versionEmitted, declared, version;
|
||||
ctmbstr extra_string = NULL;
|
||||
|
||||
TagToString(node, nodedesc, sizeof(nodedesc));
|
||||
|
||||
switch ( code )
|
||||
{
|
||||
case MISSING_STARTTAG:
|
||||
case UNEXPECTED_ENDTAG:
|
||||
case TOO_MANY_ELEMENTS:
|
||||
case INSERTING_TAG:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyWarning, node->element );
|
||||
break;
|
||||
|
||||
case USING_BR_INPLACE_OF:
|
||||
case CANT_BE_NESTED:
|
||||
case PROPRIETARY_ELEMENT:
|
||||
case UNESCAPED_ELEMENT:
|
||||
case NOFRAMES_CONTENT:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyWarning, nodedesc );
|
||||
break;
|
||||
|
||||
case ELEMENT_VERS_MISMATCH_WARN:
|
||||
versionEmitted = doc->lexer->versionEmitted;
|
||||
declared = doc->lexer->doctype;
|
||||
version = versionEmitted == 0 ? declared : versionEmitted;
|
||||
extra_string = TY_(HTMLVersionNameFromCode)(version, 0);
|
||||
if (!extra_string)
|
||||
extra_string = tidyLocalizedString(STRING_HTML_PROPRIETARY);
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyWarning, nodedesc, extra_string );
|
||||
break;
|
||||
|
||||
case ELEMENT_VERS_MISMATCH_ERROR:
|
||||
versionEmitted = doc->lexer->versionEmitted;
|
||||
|
@ -346,54 +340,11 @@ void TY_(ReportError)(TidyDocImpl* doc, Node *element, Node *node, uint code)
|
|||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyError, nodedesc, extra_string );
|
||||
break;
|
||||
|
||||
case MISSING_TITLE_ELEMENT:
|
||||
case INCONSISTENT_VERSION:
|
||||
case MALFORMED_DOCTYPE:
|
||||
case CONTENT_AFTER_BODY:
|
||||
case MALFORMED_COMMENT:
|
||||
case BAD_COMMENT_CHARS:
|
||||
case BAD_XML_COMMENT:
|
||||
case BAD_CDATA_CONTENT:
|
||||
case INCONSISTENT_NAMESPACE:
|
||||
case DOCTYPE_AFTER_TAGS:
|
||||
case DTYPE_NOT_UPPER_CASE:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning );
|
||||
break;
|
||||
|
||||
case COERCE_TO_ENDTAG:
|
||||
case NON_MATCHING_ENDTAG:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, node->element, node->element );
|
||||
break;
|
||||
|
||||
case UNEXPECTED_ENDTAG_IN:
|
||||
case TOO_MANY_ELEMENTS_IN:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyWarning, node->element, node->element );
|
||||
message2 = TY_(tidyMessageCreateWithNode)(doc, node, PREVIOUS_LOCATION, TidyInfo, element->element );
|
||||
break;
|
||||
|
||||
case ENCODING_IO_CONFLICT:
|
||||
case MISSING_DOCTYPE:
|
||||
case SPACE_PRECEDING_XMLDECL:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyWarning );
|
||||
break;
|
||||
|
||||
case TRIM_EMPTY_ELEMENT:
|
||||
case ILLEGAL_NESTING:
|
||||
case UNEXPECTED_END_OF_FILE:
|
||||
case ELEMENT_NOT_EMPTY:
|
||||
TagToString(element, elemdesc, sizeof(elemdesc));
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, element, code, TidyWarning, elemdesc );
|
||||
break;
|
||||
|
||||
|
||||
case MISSING_ENDTAG_FOR:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, element->element );
|
||||
break;
|
||||
|
||||
case MISSING_ENDTAG_BEFORE:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, element->element, nodedesc );
|
||||
break;
|
||||
|
||||
case DISCARDING_UNEXPECTED:
|
||||
/* Force error if in a bad form, or
|
||||
Issue #166 - repeated <main> element
|
||||
|
@ -406,34 +357,8 @@ void TY_(ReportError)(TidyDocImpl* doc, Node *element, Node *node, uint code)
|
|||
message2 = TY_(tidyMessageCreateWithNode)(doc, element, PREVIOUS_LOCATION, TidyInfo, element->element );
|
||||
break;
|
||||
|
||||
case REPLACING_UNEX_ELEMENT:
|
||||
TagToString(element, elemdesc, sizeof(elemdesc));
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyWarning, elemdesc, nodedesc );
|
||||
break;
|
||||
case REMOVED_HTML5:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyError, nodedesc );
|
||||
break;
|
||||
}
|
||||
|
||||
messageOut( message );
|
||||
|
||||
/* Although the callback is always executed for message2, it's only
|
||||
added to the output sink TidyShowWarnings is enabled. */
|
||||
if (cfgBool( doc, TidyShowWarnings ))
|
||||
messageOut( message2 );
|
||||
}
|
||||
|
||||
|
||||
void TY_(ReportFatal)( TidyDocImpl* doc, Node *element, Node *node, uint code)
|
||||
{
|
||||
TidyMessageImpl *message = NULL;
|
||||
char nodedesc[ 256 ] = {0};
|
||||
Node* rpt = ( element ? element : node );
|
||||
|
||||
switch ( code )
|
||||
{
|
||||
case SUSPECTED_MISSING_QUOTE:
|
||||
case DUPLICATE_FRAMESET:
|
||||
case SUSPECTED_MISSING_QUOTE:
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, rpt, code, TidyError );
|
||||
break;
|
||||
|
||||
|
@ -447,12 +372,17 @@ void TY_(ReportFatal)( TidyDocImpl* doc, Node *element, Node *node, uint code)
|
|||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyError, node->element, element->element );
|
||||
break;
|
||||
|
||||
case UNEXPECTED_ENDTAG: /* generated by XML docs */
|
||||
case UNEXPECTED_ENDTAG_ERR: /* generated by XML docs */
|
||||
message = TY_(tidyMessageCreateWithNode)(doc, node, code, TidyError, node->element );
|
||||
break;
|
||||
}
|
||||
|
||||
messageOut( message );
|
||||
|
||||
/* Although the callback is always executed for message2, it's only
|
||||
added to the output sink TidyShowWarnings is enabled. */
|
||||
if (cfgBool( doc, TidyShowWarnings ))
|
||||
messageOut( message2 );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -49,9 +49,6 @@ ctmbstr TY_(tidyLibraryVersion)(void);
|
|||
|
||||
|
||||
void TY_(ReportNotice)(TidyDocImpl* doc, Node *element, Node *node, uint code);
|
||||
void TY_(ReportWarning)(TidyDocImpl* doc, Node *element, Node *node, uint code);
|
||||
void TY_(ReportError)(TidyDocImpl* doc, Node* element, Node* node, uint code);
|
||||
void TY_(ReportFatal)(TidyDocImpl* doc, Node* element, Node* node, uint code);
|
||||
|
||||
|
||||
/** @} */
|
||||
|
|
362
src/parser.c
362
src/parser.c
File diff suppressed because it is too large
Load diff
|
@ -990,7 +990,7 @@ void CheckTABLE( TidyDocImpl* doc, Node *node )
|
|||
if (HasSummary && isHTML5)
|
||||
{
|
||||
/* #210 - has summary, and is HTML5, then report obsolete */
|
||||
TY_(ReportWarning)(doc, node, node, BAD_SUMMARY_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, BAD_SUMMARY_HTML5);
|
||||
}
|
||||
else if (!HasSummary && !isHTML5)
|
||||
{
|
||||
|
|
|
@ -1640,7 +1640,7 @@ void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node )
|
|||
TY_(CoerceNode)(doc, node, TidyTag_ABBR, warn, no);
|
||||
} else {
|
||||
if ( !already_strict )
|
||||
TY_(ReportWarning)(doc, node, node, REMOVED_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, REMOVED_HTML5);
|
||||
}
|
||||
} else
|
||||
if ( nodeIsAPPLET(node) ) {
|
||||
|
@ -1651,7 +1651,7 @@ void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node )
|
|||
TY_(CoerceNode)(doc, node, TidyTag_OBJECT, warn, no);
|
||||
} else {
|
||||
if ( !already_strict )
|
||||
TY_(ReportWarning)(doc, node, node, REMOVED_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, REMOVED_HTML5);
|
||||
}
|
||||
} else
|
||||
if ( nodeIsBASEFONT(node) ) {
|
||||
|
@ -1664,7 +1664,7 @@ void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node )
|
|||
* - For now just report a warning
|
||||
*/
|
||||
if ( !already_strict )
|
||||
TY_(ReportWarning)(doc, node, node, REMOVED_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, REMOVED_HTML5);
|
||||
} else
|
||||
if ( nodeIsBIG(node) ) {
|
||||
/* big: CSS equivalent 'font-size:larger'
|
||||
|
@ -1686,7 +1686,7 @@ void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node )
|
|||
TY_(CoerceNode)(doc, node, TidyTag_SPAN, warn, no);
|
||||
} else {
|
||||
if ( !already_strict )
|
||||
TY_(ReportWarning)(doc, node, node, REMOVED_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, REMOVED_HTML5);
|
||||
}
|
||||
} else
|
||||
if ( nodeIsCENTER(node) ) {
|
||||
|
@ -1697,7 +1697,7 @@ void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node )
|
|||
* see: static Bool Center2Div( TidyDocImpl* doc, Node *node, Node **pnode)
|
||||
*/
|
||||
if ( !already_strict )
|
||||
TY_(ReportWarning)(doc, node, node, REMOVED_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, REMOVED_HTML5);
|
||||
} else
|
||||
if ( nodeIsDIR(node) ) {
|
||||
/* dir: replace by <ul>
|
||||
|
@ -1705,7 +1705,7 @@ void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node )
|
|||
* Should this be CHANGED???
|
||||
*/
|
||||
if ( !already_strict )
|
||||
TY_(ReportWarning)(doc, node, node, REMOVED_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, REMOVED_HTML5);
|
||||
} else
|
||||
if ( nodeIsFONT(node) ) {
|
||||
/* Tidy already handles this -
|
||||
|
@ -1714,13 +1714,13 @@ void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node )
|
|||
* done in Bool Font2Span( TidyDocImpl* doc, Node *node, Node **pnode ) (I think?)
|
||||
*/
|
||||
if ( !already_strict )
|
||||
TY_(ReportWarning)(doc, node, node, REMOVED_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, REMOVED_HTML5);
|
||||
} else
|
||||
if (( nodesIsFRAME(node) ) || ( nodeIsFRAMESET(node) ) || ( nodeIsNOFRAMES(node) )) {
|
||||
/* YOW: What to do here?????? Maybe <iframe>????
|
||||
*/
|
||||
if ( !already_strict )
|
||||
TY_(ReportWarning)(doc, node, node, REMOVED_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, REMOVED_HTML5);
|
||||
} else
|
||||
if ( nodeIsSTRIKE(node) ) {
|
||||
/* strike: CSS equivalent 'text-decoration:line-through'
|
||||
|
@ -1731,7 +1731,7 @@ void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node )
|
|||
TY_(CoerceNode)(doc, node, TidyTag_SPAN, warn, no);
|
||||
} else {
|
||||
if ( !already_strict )
|
||||
TY_(ReportWarning)(doc, node, node, REMOVED_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, REMOVED_HTML5);
|
||||
}
|
||||
} else
|
||||
if ( nodeIsTT(node) ) {
|
||||
|
@ -1745,14 +1745,14 @@ void TY_(CheckHTML5)( TidyDocImpl* doc, Node* node )
|
|||
TY_(CoerceNode)(doc, node, TidyTag_SPAN, warn, no);
|
||||
} else {
|
||||
if ( !already_strict )
|
||||
TY_(ReportWarning)(doc, node, node, REMOVED_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, REMOVED_HTML5);
|
||||
}
|
||||
} else
|
||||
if (TY_(nodeIsElement)(node)) {
|
||||
if (node->tag) {
|
||||
if ( (!(node->tag->versions & VERS_HTML5) && !(node->tag->versions & VERS_PROPRIETARY)) || (inRemovedInfo(node->tag->id)) ) {
|
||||
if ( !already_strict )
|
||||
TY_(ReportWarning)(doc, node, node, REMOVED_HTML5);
|
||||
TY_(ReportNotice)(doc, node, node, REMOVED_HTML5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1805,7 +1805,7 @@ void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node )
|
|||
/* Version mismatches take priority. */
|
||||
if ( check_versions && !(node->tag->versions & version) )
|
||||
{
|
||||
TY_(ReportError)(doc, NULL, node, tagReportType );
|
||||
TY_(ReportNotice)(doc, NULL, node, tagReportType );
|
||||
}
|
||||
/* If it's not mismatched, it could still be proprietary. */
|
||||
else if ( node->tag->versions & VERS_PROPRIETARY )
|
||||
|
@ -1825,7 +1825,7 @@ void TY_(CheckHTMLTagsAttribsVersions)( TidyDocImpl* doc, Node* node )
|
|||
|
||||
if ( (htmlIs5 && !tagLooksCustom) || !htmlIs5 )
|
||||
{
|
||||
TY_(ReportError)(doc, NULL, node, PROPRIETARY_ELEMENT );
|
||||
TY_(ReportNotice)(doc, NULL, node, PROPRIETARY_ELEMENT );
|
||||
}
|
||||
|
||||
if ( nodeIsLAYER(node) )
|
||||
|
@ -2140,7 +2140,7 @@ int tidyDocCleanAndRepair( TidyDocImpl* doc )
|
|||
|
||||
if ( !doc->lexer->isvoyager && doc->xmlDetected )
|
||||
{
|
||||
TY_(ReportWarning)(doc, NULL, TY_(FindXmlDecl)(doc), XML_DECLARATION_DETECTED );
|
||||
TY_(ReportNotice)(doc, NULL, TY_(FindXmlDecl)(doc), XML_DECLARATION_DETECTED );
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue