Address #575 by adding a new footnote in TY_(ErrorSummary) suggesting that if

this behavior is not wanted, then which option to use to prevent it.
This commit is contained in:
Jim Derry 2017-09-29 11:25:17 -04:00
parent d6c974b672
commit b0f584fa24
7 changed files with 87 additions and 51 deletions

View file

@ -122,27 +122,28 @@ extern "C" {
** than the short report. ** than the short report.
*/ */
#define FOREACH_FOOTNOTE_MSG(FN) \ #define FOREACH_FOOTNOTE_MSG(FN) \
/** Explanatory text. */ FN(TEXT_ACCESS_ADVICE1) \ FN(FOOTNOTE_TRIM_EMPTY_ELEMENT) \
/** Explanatory text. */ FN(TEXT_ACCESS_ADVICE2) \ FN(TEXT_ACCESS_ADVICE1) \
/** Explanatory text. */ FN(TEXT_BAD_FORM) \ FN(TEXT_ACCESS_ADVICE2) \
/** Explanatory text. */ FN(TEXT_BAD_MAIN) \ FN(TEXT_BAD_FORM) \
/** Explanatory text. */ FN(TEXT_HTML_T_ALGORITHM) \ FN(TEXT_BAD_MAIN) \
/** Explanatory text. */ FN(TEXT_INVALID_URI) \ FN(TEXT_HTML_T_ALGORITHM) \
/** Explanatory text. */ FN(TEXT_INVALID_UTF16) \ FN(TEXT_INVALID_URI) \
/** Explanatory text. */ FN(TEXT_INVALID_UTF8) \ FN(TEXT_INVALID_UTF16) \
/** Explanatory text. */ FN(TEXT_M_IMAGE_ALT) \ FN(TEXT_INVALID_UTF8) \
/** Explanatory text. */ FN(TEXT_M_IMAGE_MAP) \ FN(TEXT_M_IMAGE_ALT) \
/** Explanatory text. */ FN(TEXT_M_LINK_ALT) \ FN(TEXT_M_IMAGE_MAP) \
/** Explanatory text. */ FN(TEXT_M_SUMMARY) \ FN(TEXT_M_LINK_ALT) \
/** Explanatory text. */ FN(TEXT_SGML_CHARS) \ FN(TEXT_M_SUMMARY) \
/** Explanatory text. */ FN(TEXT_USING_BODY) \ FN(TEXT_SGML_CHARS) \
/** Explanatory text. */ FN(TEXT_USING_FONT) \ FN(TEXT_USING_BODY) \
/** Explanatory text. */ FN(TEXT_USING_FRAMES) \ FN(TEXT_USING_FONT) \
/** Explanatory text. */ FN(TEXT_USING_LAYER) \ FN(TEXT_USING_FRAMES) \
/** Explanatory text. */ FN(TEXT_USING_NOBR) \ FN(TEXT_USING_LAYER) \
/** Explanatory text. */ FN(TEXT_USING_SPACER) \ FN(TEXT_USING_NOBR) \
/** Explanatory text. */ FN(TEXT_VENDOR_CHARS) \ FN(TEXT_USING_SPACER) \
/** Explanatory text. */ FN(TEXT_WINDOWS_CHARS) FN(TEXT_VENDOR_CHARS) \
FN(TEXT_WINDOWS_CHARS)
/** These messages are used to generate additional dialogue style output from /** These messages are used to generate additional dialogue style output from

View file

@ -5,7 +5,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n" "Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: HTML Tidy poconvert.rb\n" "X-Generator: HTML Tidy poconvert.rb\n"
"Project-Id-Version: \n" "Project-Id-Version: \n"
"POT-Creation-Date: 2017-09-28 13:24:51\n" "POT-Creation-Date: 2017-09-29 11:24:53\n"
"Last-Translator: jderry\n" "Last-Translator: jderry\n"
"Language-Team: \n" "Language-Team: \n"
@ -1980,6 +1980,15 @@ msgid ""
"include an alternative layout inside a NOFRAMES element.\n" "include an alternative layout inside a NOFRAMES element.\n"
msgstr "" msgstr ""
#. This console output should be limited to 78 characters per line.
msgctxt "FOOTNOTE_TRIM_EMPTY_ELEMENT"
msgid ""
"One or more empty elements were present in the source document but\n"
"dropped on output. If these elements are necessary or you don't want\n"
"this behavior, then consider setting the option \"drop-empty-elements\"\n"
"to no.\n"
msgstr ""
#. This console output should be limited to 78 characters per line. #. This console output should be limited to 78 characters per line.
#. - The URL should not be translated unless you find a matching URL in your language. #. - The URL should not be translated unless you find a matching URL in your language.
msgctxt "TEXT_ACCESS_ADVICE1" msgctxt "TEXT_ACCESS_ADVICE1"

View file

@ -1761,6 +1761,13 @@ static languageDefinition language_en = { whichPluralForm_en, {
"doesn't support frames. A frames-based page should always\n" "doesn't support frames. A frames-based page should always\n"
"include an alternative layout inside a NOFRAMES element.\n" "include an alternative layout inside a NOFRAMES element.\n"
}, },
{/* This console output should be limited to 78 characters per line. */
FOOTNOTE_TRIM_EMPTY_ELEMENT, 0,
"One or more empty elements were present in the source document but\n"
"dropped on output. If these elements are necessary or you don't want\n"
"this behavior, then consider setting the option \"drop-empty-elements\"\n"
"to no.\n"
},
{/* This console output should be limited to 78 characters per line. {/* This console output should be limited to 78 characters per line.
- The URL should not be translated unless you find a matching URL in your language. */ - The URL should not be translated unless you find a matching URL in your language. */
TEXT_ACCESS_ADVICE1, 0, TEXT_ACCESS_ADVICE1, 0,

View file

@ -1001,35 +1001,38 @@ static struct _dialogueDispatchTable {
uint code; /**< The message code. */ uint code; /**< The message code. */
TidyReportLevel level; /**< The default TidyReportLevel of the message. */ TidyReportLevel level; /**< The default TidyReportLevel of the message. */
} dialogueDispatchTable[] = { } dialogueDispatchTable[] = {
{ STRING_HELLO_ACCESS, TidyDialogueInfo }, /* AccessibilityChecks() */ { STRING_HELLO_ACCESS, TidyDialogueInfo }, /* AccessibilityChecks() */
{ TEXT_GENERAL_INFO, TidyDialogueInfo }, /* tidyGeneralInfo() */ { TEXT_GENERAL_INFO, TidyDialogueInfo }, /* tidyGeneralInfo() */
{ TEXT_GENERAL_INFO_PLEA, TidyDialogueInfo }, /* tidyGeneralInfo() */ { TEXT_GENERAL_INFO_PLEA, TidyDialogueInfo }, /* tidyGeneralInfo() */
{ STRING_NEEDS_INTERVENTION, TidyDialogueSummary }, /* tidyDocRunDiagnostics() */ { STRING_NEEDS_INTERVENTION, TidyDialogueSummary }, /* tidyDocRunDiagnostics() */
{ STRING_ERROR_COUNT, TidyDialogueSummary }, /* ReportNumWarnings() */ { STRING_ERROR_COUNT, TidyDialogueSummary }, /* ReportNumWarnings() */
{ STRING_NO_ERRORS, TidyDialogueSummary }, /* ReportNumWarnings() */ { STRING_NO_ERRORS, TidyDialogueSummary }, /* ReportNumWarnings() */
{ STRING_NOT_ALL_SHOWN, TidyDialogueSummary }, /* ReportNumWarnings() */ { STRING_NOT_ALL_SHOWN, TidyDialogueSummary }, /* ReportNumWarnings() */
{ TEXT_ACCESS_ADVICE1, TidyDialogueFootnote }, /* errorSummary() */ { FOOTNOTE_TRIM_EMPTY_ELEMENT, TidyDialogueFootnote },
{ TEXT_ACCESS_ADVICE2, TidyDialogueFootnote }, { TEXT_ACCESS_ADVICE1, TidyDialogueFootnote }, /* errorSummary() */
{ TEXT_BAD_FORM, TidyDialogueFootnote }, { TEXT_ACCESS_ADVICE2, TidyDialogueFootnote },
{ TEXT_BAD_MAIN, TidyDialogueFootnote }, { TEXT_BAD_FORM, TidyDialogueFootnote },
{ TEXT_HTML_T_ALGORITHM, TidyDialogueFootnote }, { TEXT_BAD_MAIN, TidyDialogueFootnote },
{ TEXT_INVALID_URI, TidyDialogueFootnote }, { TEXT_HTML_T_ALGORITHM, TidyDialogueFootnote },
{ TEXT_INVALID_UTF8, TidyDialogueFootnote }, { TEXT_INVALID_URI, TidyDialogueFootnote },
{ TEXT_INVALID_UTF16, TidyDialogueFootnote }, { TEXT_INVALID_UTF8, TidyDialogueFootnote },
{ TEXT_M_IMAGE_ALT, TidyDialogueFootnote }, { TEXT_INVALID_UTF16, TidyDialogueFootnote },
{ TEXT_M_IMAGE_MAP, TidyDialogueFootnote }, { TEXT_M_IMAGE_ALT, TidyDialogueFootnote },
{ TEXT_M_LINK_ALT, TidyDialogueFootnote }, { TEXT_M_IMAGE_MAP, TidyDialogueFootnote },
{ TEXT_M_SUMMARY, TidyDialogueFootnote }, { TEXT_M_LINK_ALT, TidyDialogueFootnote },
{ TEXT_SGML_CHARS, TidyDialogueFootnote }, { TEXT_M_SUMMARY, TidyDialogueFootnote },
{ TEXT_USING_BODY, TidyDialogueFootnote }, { TEXT_SGML_CHARS, TidyDialogueFootnote },
{ TEXT_USING_FONT, TidyDialogueFootnote }, { TEXT_USING_BODY, TidyDialogueFootnote },
{ TEXT_USING_FRAMES, TidyDialogueFootnote }, { TEXT_USING_FONT, TidyDialogueFootnote },
{ TEXT_USING_LAYER, TidyDialogueFootnote }, { TEXT_USING_FRAMES, TidyDialogueFootnote },
{ TEXT_USING_NOBR, TidyDialogueFootnote }, { TEXT_USING_LAYER, TidyDialogueFootnote },
{ TEXT_USING_SPACER, TidyDialogueFootnote }, { TEXT_USING_NOBR, TidyDialogueFootnote },
{ TEXT_VENDOR_CHARS, TidyDialogueFootnote }, { TEXT_USING_SPACER, TidyDialogueFootnote },
{ TEXT_VENDOR_CHARS, TidyDialogueFootnote },
{ 0, 0 }
}; };
@ -1054,6 +1057,7 @@ TidyMessageImpl *formatDialogue( TidyDocImpl* doc, uint code, TidyReportLevel le
doc->warnings, tidyLocalizedStringN( STRING_ERROR_COUNT_WARNING, doc->warnings ), doc->warnings, tidyLocalizedStringN( STRING_ERROR_COUNT_WARNING, doc->warnings ),
doc->errors, tidyLocalizedStringN( STRING_ERROR_COUNT_ERROR, doc->errors ) ); doc->errors, tidyLocalizedStringN( STRING_ERROR_COUNT_ERROR, doc->errors ) );
case FOOTNOTE_TRIM_EMPTY_ELEMENT:
case STRING_HELLO_ACCESS: case STRING_HELLO_ACCESS:
case STRING_NEEDS_INTERVENTION: case STRING_NEEDS_INTERVENTION:
case STRING_NO_ERRORS: case STRING_NO_ERRORS:
@ -1222,6 +1226,13 @@ void TY_(ErrorSummary)( TidyDocImpl* doc )
if (doc->badLayout & USING_BODY) if (doc->badLayout & USING_BODY)
TY_(Dialogue)( doc, TEXT_USING_BODY ); TY_(Dialogue)( doc, TEXT_USING_BODY );
} }
if (doc->footnotes)
{
if (doc->footnotes & FN_TRIM_EMPTY_ELEMENT)
TY_(Dialogue)( doc, FOOTNOTE_TRIM_EMPTY_ELEMENT );
}
} }

View file

@ -260,6 +260,10 @@ uint TY_(getNextErrorCode)( TidyIterator* iter );
#define BC_INVALID_URI 32 #define BC_INVALID_URI 32
#define BC_INVALID_NCR 64 #define BC_INVALID_NCR 64
/* other footnote bit field (temporary until formalized) */
#define FN_TRIM_EMPTY_ELEMENT 1
/* Lexer and I/O Macros */ /* Lexer and I/O Macros */
#define REPLACED_CHAR 0 #define REPLACED_CHAR 0

View file

@ -336,8 +336,11 @@ Node *TY_(TrimEmptyElement)( TidyDocImpl* doc, Node *element )
{ {
if ( CanPrune(doc, element) ) if ( CanPrune(doc, element) )
{ {
if (element->type != TextNode) if (element->type != TextNode)
{
doc->footnotes |= FN_TRIM_EMPTY_ELEMENT;
TY_(Report)(doc, element, NULL, TRIM_EMPTY_ELEMENT); TY_(Report)(doc, element, NULL, TRIM_EMPTY_ELEMENT);
}
return TY_(DiscardElement)(doc, element); return TY_(DiscardElement)(doc, element);
} }

View file

@ -76,6 +76,7 @@ struct _TidyDocImpl
uint badLayout; /* for bad style errors */ uint badLayout; /* for bad style errors */
uint badChars; /* for bad char encodings */ uint badChars; /* for bad char encodings */
uint badForm; /* bit field, for badly placed form tags, or other format errors */ uint badForm; /* bit field, for badly placed form tags, or other format errors */
uint footnotes; /* bit field, for other footnotes, until formalized */
Bool HTML5Mode; /* current mode is html5 */ Bool HTML5Mode; /* current mode is html5 */
Bool xmlDetected; /* true if XML was used/detected */ Bool xmlDetected; /* true if XML was used/detected */