diff --git a/include/tidyenum.h b/include/tidyenum.h index d88e86d..53f8afe 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -122,27 +122,28 @@ extern "C" { ** than the short report. */ #define FOREACH_FOOTNOTE_MSG(FN) \ -/** Explanatory text. */ FN(TEXT_ACCESS_ADVICE1) \ -/** Explanatory text. */ FN(TEXT_ACCESS_ADVICE2) \ -/** Explanatory text. */ FN(TEXT_BAD_FORM) \ -/** Explanatory text. */ FN(TEXT_BAD_MAIN) \ -/** Explanatory text. */ FN(TEXT_HTML_T_ALGORITHM) \ -/** Explanatory text. */ FN(TEXT_INVALID_URI) \ -/** Explanatory text. */ FN(TEXT_INVALID_UTF16) \ -/** Explanatory text. */ FN(TEXT_INVALID_UTF8) \ -/** Explanatory text. */ FN(TEXT_M_IMAGE_ALT) \ -/** Explanatory text. */ FN(TEXT_M_IMAGE_MAP) \ -/** Explanatory text. */ FN(TEXT_M_LINK_ALT) \ -/** Explanatory text. */ FN(TEXT_M_SUMMARY) \ -/** Explanatory text. */ FN(TEXT_SGML_CHARS) \ -/** Explanatory text. */ FN(TEXT_USING_BODY) \ -/** Explanatory text. */ FN(TEXT_USING_FONT) \ -/** Explanatory text. */ FN(TEXT_USING_FRAMES) \ -/** Explanatory text. */ FN(TEXT_USING_LAYER) \ -/** Explanatory text. */ FN(TEXT_USING_NOBR) \ -/** Explanatory text. */ FN(TEXT_USING_SPACER) \ -/** Explanatory text. */ FN(TEXT_VENDOR_CHARS) \ -/** Explanatory text. */ FN(TEXT_WINDOWS_CHARS) + FN(FOOTNOTE_TRIM_EMPTY_ELEMENT) \ + FN(TEXT_ACCESS_ADVICE1) \ + FN(TEXT_ACCESS_ADVICE2) \ + FN(TEXT_BAD_FORM) \ + FN(TEXT_BAD_MAIN) \ + FN(TEXT_HTML_T_ALGORITHM) \ + FN(TEXT_INVALID_URI) \ + FN(TEXT_INVALID_UTF16) \ + FN(TEXT_INVALID_UTF8) \ + FN(TEXT_M_IMAGE_ALT) \ + FN(TEXT_M_IMAGE_MAP) \ + FN(TEXT_M_LINK_ALT) \ + FN(TEXT_M_SUMMARY) \ + FN(TEXT_SGML_CHARS) \ + FN(TEXT_USING_BODY) \ + FN(TEXT_USING_FONT) \ + FN(TEXT_USING_FRAMES) \ + FN(TEXT_USING_LAYER) \ + FN(TEXT_USING_NOBR) \ + FN(TEXT_USING_SPACER) \ + FN(TEXT_VENDOR_CHARS) \ + FN(TEXT_WINDOWS_CHARS) /** These messages are used to generate additional dialogue style output from diff --git a/localize/translations/tidy.pot b/localize/translations/tidy.pot index aee2879..9399ea6 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-09-28 13:24:51\n" +"POT-Creation-Date: 2017-09-29 11:24:53\n" "Last-Translator: jderry\n" "Language-Team: \n" @@ -1980,6 +1980,15 @@ msgid "" "include an alternative layout inside a NOFRAMES element.\n" 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. #. - The URL should not be translated unless you find a matching URL in your language. msgctxt "TEXT_ACCESS_ADVICE1" diff --git a/src/language_en.h b/src/language_en.h index 97291e6..d3669ca 100644 --- a/src/language_en.h +++ b/src/language_en.h @@ -1761,6 +1761,13 @@ static languageDefinition language_en = { whichPluralForm_en, { "doesn't support frames. A frames-based page should always\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. - The URL should not be translated unless you find a matching URL in your language. */ TEXT_ACCESS_ADVICE1, 0, diff --git a/src/message.c b/src/message.c index dbfd303..1a031ea 100644 --- a/src/message.c +++ b/src/message.c @@ -1001,35 +1001,38 @@ static struct _dialogueDispatchTable { uint code; /**< The message code. */ TidyReportLevel level; /**< The default TidyReportLevel of the message. */ } dialogueDispatchTable[] = { - { STRING_HELLO_ACCESS, TidyDialogueInfo }, /* AccessibilityChecks() */ - { TEXT_GENERAL_INFO, TidyDialogueInfo }, /* tidyGeneralInfo() */ - { TEXT_GENERAL_INFO_PLEA, TidyDialogueInfo }, /* tidyGeneralInfo() */ + { STRING_HELLO_ACCESS, TidyDialogueInfo }, /* AccessibilityChecks() */ + { TEXT_GENERAL_INFO, TidyDialogueInfo }, /* tidyGeneralInfo() */ + { TEXT_GENERAL_INFO_PLEA, TidyDialogueInfo }, /* tidyGeneralInfo() */ - { STRING_NEEDS_INTERVENTION, TidyDialogueSummary }, /* tidyDocRunDiagnostics() */ - { STRING_ERROR_COUNT, TidyDialogueSummary }, /* ReportNumWarnings() */ - { STRING_NO_ERRORS, TidyDialogueSummary }, /* ReportNumWarnings() */ - { STRING_NOT_ALL_SHOWN, TidyDialogueSummary }, /* ReportNumWarnings() */ + { STRING_NEEDS_INTERVENTION, TidyDialogueSummary }, /* tidyDocRunDiagnostics() */ + { STRING_ERROR_COUNT, TidyDialogueSummary }, /* ReportNumWarnings() */ + { STRING_NO_ERRORS, TidyDialogueSummary }, /* ReportNumWarnings() */ + { STRING_NOT_ALL_SHOWN, TidyDialogueSummary }, /* ReportNumWarnings() */ - { TEXT_ACCESS_ADVICE1, TidyDialogueFootnote }, /* errorSummary() */ - { TEXT_ACCESS_ADVICE2, TidyDialogueFootnote }, - { TEXT_BAD_FORM, TidyDialogueFootnote }, - { TEXT_BAD_MAIN, TidyDialogueFootnote }, - { TEXT_HTML_T_ALGORITHM, TidyDialogueFootnote }, - { TEXT_INVALID_URI, TidyDialogueFootnote }, - { TEXT_INVALID_UTF8, TidyDialogueFootnote }, - { TEXT_INVALID_UTF16, TidyDialogueFootnote }, - { TEXT_M_IMAGE_ALT, TidyDialogueFootnote }, - { TEXT_M_IMAGE_MAP, TidyDialogueFootnote }, - { TEXT_M_LINK_ALT, TidyDialogueFootnote }, - { TEXT_M_SUMMARY, TidyDialogueFootnote }, - { TEXT_SGML_CHARS, TidyDialogueFootnote }, - { TEXT_USING_BODY, TidyDialogueFootnote }, - { TEXT_USING_FONT, TidyDialogueFootnote }, - { TEXT_USING_FRAMES, TidyDialogueFootnote }, - { TEXT_USING_LAYER, TidyDialogueFootnote }, - { TEXT_USING_NOBR, TidyDialogueFootnote }, - { TEXT_USING_SPACER, TidyDialogueFootnote }, - { TEXT_VENDOR_CHARS, TidyDialogueFootnote }, + { FOOTNOTE_TRIM_EMPTY_ELEMENT, TidyDialogueFootnote }, + { TEXT_ACCESS_ADVICE1, TidyDialogueFootnote }, /* errorSummary() */ + { TEXT_ACCESS_ADVICE2, TidyDialogueFootnote }, + { TEXT_BAD_FORM, TidyDialogueFootnote }, + { TEXT_BAD_MAIN, TidyDialogueFootnote }, + { TEXT_HTML_T_ALGORITHM, TidyDialogueFootnote }, + { TEXT_INVALID_URI, TidyDialogueFootnote }, + { TEXT_INVALID_UTF8, TidyDialogueFootnote }, + { TEXT_INVALID_UTF16, TidyDialogueFootnote }, + { TEXT_M_IMAGE_ALT, TidyDialogueFootnote }, + { TEXT_M_IMAGE_MAP, TidyDialogueFootnote }, + { TEXT_M_LINK_ALT, TidyDialogueFootnote }, + { TEXT_M_SUMMARY, TidyDialogueFootnote }, + { TEXT_SGML_CHARS, TidyDialogueFootnote }, + { TEXT_USING_BODY, TidyDialogueFootnote }, + { TEXT_USING_FONT, TidyDialogueFootnote }, + { TEXT_USING_FRAMES, TidyDialogueFootnote }, + { TEXT_USING_LAYER, TidyDialogueFootnote }, + { TEXT_USING_NOBR, 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->errors, tidyLocalizedStringN( STRING_ERROR_COUNT_ERROR, doc->errors ) ); + case FOOTNOTE_TRIM_EMPTY_ELEMENT: case STRING_HELLO_ACCESS: case STRING_NEEDS_INTERVENTION: case STRING_NO_ERRORS: @@ -1222,6 +1226,13 @@ void TY_(ErrorSummary)( TidyDocImpl* doc ) if (doc->badLayout & 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 ); + } + } diff --git a/src/message.h b/src/message.h index 9914891..75a0cd9 100644 --- a/src/message.h +++ b/src/message.h @@ -260,6 +260,10 @@ uint TY_(getNextErrorCode)( TidyIterator* iter ); #define BC_INVALID_URI 32 #define BC_INVALID_NCR 64 +/* other footnote bit field (temporary until formalized) */ + +#define FN_TRIM_EMPTY_ELEMENT 1 + /* Lexer and I/O Macros */ #define REPLACED_CHAR 0 diff --git a/src/parser.c b/src/parser.c index f27e726..05a6b9b 100644 --- a/src/parser.c +++ b/src/parser.c @@ -336,9 +336,12 @@ Node *TY_(TrimEmptyElement)( TidyDocImpl* doc, Node *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); - + } + return TY_(DiscardElement)(doc, element); } return element->next; diff --git a/src/tidy-int.h b/src/tidy-int.h index 6bcfaf5..91ced4b 100644 --- a/src/tidy-int.h +++ b/src/tidy-int.h @@ -76,6 +76,7 @@ struct _TidyDocImpl uint badLayout; /* for bad style errors */ uint badChars; /* for bad char encodings */ 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 xmlDetected; /* true if XML was used/detected */