Merge pull request #629 from htacg/squelch_reports

Squelch reports
This commit is contained in:
Jim Derry 2017-10-19 17:21:37 -04:00 committed by GitHub
commit 93957e4b17
19 changed files with 551 additions and 46 deletions

View file

@ -1248,7 +1248,16 @@ TIDY_EXPORT int TIDY_CALL tidyGetMessageColumn( TidyMessage tmessage );
** message.
*/
TIDY_EXPORT TidyReportLevel TIDY_CALL tidyGetMessageLevel( TidyMessage tmessage );
/** Get the muted status of the message, that is, whether or not the
** current configuration indicated that this message should be muted.
** @param tmessage Specify the message that you are querying.
** @result Returns a Bool indicating that the config indicates muting this
** message.
*/
TIDY_EXPORT Bool TIDY_CALL tidyGetMessageIsMuted( TidyMessage tmessage );
/** Get the default format string, which is the format string for the message
** in Tidy's default localization (en_us).
** @param tmessage Specify the message that you are querying.

View file

@ -157,12 +157,9 @@ extern "C" {
** than the short report.
*/
#define FOREACH_DIALOG_MSG(FN) \
/* TidyInfo */ FN(STRING_CONTENT_LOOKS) \
/* TidyInfo */ FN(STRING_DOCTYPE_GIVEN) \
/* TidyDialogueSummary */ FN(STRING_ERROR_COUNT) \
/* TidyDialogueSummary */ FN(STRING_NEEDS_INTERVENTION) \
/* TidyDialogueSummary */ FN(STRING_NO_ERRORS) \
/* TidyInfo */ FN(STRING_NO_SYSID) \
/* TidyDialogueSummary */ FN(STRING_NOT_ALL_SHOWN) \
/* TidyDialogueInfo */ FN(TEXT_GENERAL_INFO_PLEA) \
/* TidyDialogueInfo */ FN(TEXT_GENERAL_INFO)
@ -255,7 +252,12 @@ extern "C" {
FN(REPLACING_ELEMENT) \
FN(REPLACING_UNEX_ELEMENT) \
FN(SPACE_PRECEDING_XMLDECL) \
FN(STRING_CONTENT_LOOKS) \
FN(STRING_ARGUMENT_BAD) \
FN(STRING_DOCTYPE_GIVEN) \
FN(STRING_MISSING_MALFORMED) \
FN(STRING_MUTING_TYPE) \
FN(STRING_NO_SYSID) \
FN(STRING_UNKNOWN_OPTION) \
FN(SUSPECTED_MISSING_QUOTE) \
FN(TAG_NOT_ALLOWED_IN) \
@ -636,6 +638,8 @@ typedef enum
TidyShowWarnings, /**< However errors are always shown */
TidySkipNested, /**< Skip nested tags in script and style CDATA */
TidySortAttributes, /**< Sort attributes */
TidyMuteReports, /**< Filter these messages from output. */
TidyMuteShow, /**< Show message ID's in the error table */
TidyStrictTagsAttr, /**< Ensure tags and attributes match output HTML version */
TidyStyleTags, /**< Move sytle to head */
TidyTabSize, /**< Expand tabs to n spaces */
@ -1414,7 +1418,9 @@ typedef enum
FOREACH_MSG_MISC(MAKE_ENUM)
FOREACH_FOOTNOTE_MSG(MAKE_ENUM)
FOREACH_DIALOG_MSG(MAKE_ENUM)
REPORT_MESSAGE_FIRST,
FOREACH_REPORT_MSG(MAKE_ENUM)
REPORT_MESSAGE_LAST,
FOREACH_ACCESS_MSG(MAKE_ENUM)
#if SUPPORT_CONSOLE_APP

View file

@ -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-10-07 16:24:04\n"
"PO-Revision-Date: 2017-10-10 08:20:36\n"
"Last-Translator: jderry\n"
"Language-Team: \n"
@ -1297,6 +1297,41 @@ msgid ""
"been output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteReports"
msgid ""
"Use this option to prevent Tidy from displaying certain types of "
"report output,for example, for conditions that you wish to ignore."
"<br/>"
"This option takes a list of one or more keys indicating the message "
"type to mute. You can discover these message keys by using the "
"<code>mute-id</code> configuration option and examining Tidy's "
"output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteShow"
msgid ""
"This option indicates whether or not Tidy should display message ID's "
"with each of its error reports. This could be useful if you wanted to "
"use the <code>mute</code> configuration option in order to filter "
"out certain report messages. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
@ -2535,11 +2570,21 @@ msgctxt "SPACE_PRECEDING_XMLDECL"
msgid "removing whitespace preceding XML Declaration"
msgstr ""
#, c-format
msgctxt "STRING_ARGUMENT_BAD"
msgid "option \"%s\" given bad argument \"%s\""
msgstr ""
#, c-format
msgctxt "STRING_MISSING_MALFORMED"
msgid "missing or malformed argument for option: %s"
msgstr ""
#, c-format
msgctxt "STRING_MUTING_TYPE"
msgid "messages of type \"%s\" will not be output"
msgstr ""
#, c-format
msgctxt "STRING_UNKNOWN_OPTION"
msgid "unknown option: %s"

View file

@ -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-10-07 16:24:04\n"
"PO-Revision-Date: 2017-10-10 08:20:36\n"
"Last-Translator: jderry\n"
"Language-Team: \n"
@ -1260,6 +1260,41 @@ msgid ""
"been output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteReports"
msgid ""
"Use this option to prevent Tidy from displaying certain types of "
"report output,for example, for conditions that you wish to ignore."
"<br/>"
"This option takes a list of one or more keys indicating the message "
"type to mute. You can discover these message keys by using the "
"<code>mute-id</code> configuration option and examining Tidy's "
"output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteShow"
msgid ""
"This option indicates whether or not Tidy should display message ID's "
"with each of its error reports. This could be useful if you wanted to "
"use the <code>mute</code> configuration option in order to filter "
"out certain report messages. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
@ -2479,11 +2514,21 @@ msgctxt "SPACE_PRECEDING_XMLDECL"
msgid "removing whitespace preceding XML Declaration"
msgstr ""
#, c-format
msgctxt "STRING_ARGUMENT_BAD"
msgid "option \"%s\" given bad argument \"%s\""
msgstr ""
#, c-format
msgctxt "STRING_MISSING_MALFORMED"
msgid "missing or malformed argument for option: %s"
msgstr ""
#, c-format
msgctxt "STRING_MUTING_TYPE"
msgid "messages of type \"%s\" will not be output"
msgstr ""
#, c-format
msgctxt "STRING_UNKNOWN_OPTION"
msgid "unknown option: %s"

View file

@ -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-10-07 16:24:04\n"
"PO-Revision-Date: 2017-10-10 08:20:36\n"
"Last-Translator: jderry\n"
"Language-Team: \n"
@ -1255,6 +1255,41 @@ msgid ""
"been output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteReports"
msgid ""
"Use this option to prevent Tidy from displaying certain types of "
"report output,for example, for conditions that you wish to ignore."
"<br/>"
"This option takes a list of one or more keys indicating the message "
"type to mute. You can discover these message keys by using the "
"<code>mute-id</code> configuration option and examining Tidy's "
"output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteShow"
msgid ""
"This option indicates whether or not Tidy should display message ID's "
"with each of its error reports. This could be useful if you wanted to "
"use the <code>mute</code> configuration option in order to filter "
"out certain report messages. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
@ -2474,11 +2509,21 @@ msgctxt "SPACE_PRECEDING_XMLDECL"
msgid "removing whitespace preceding XML Declaration"
msgstr ""
#, c-format
msgctxt "STRING_ARGUMENT_BAD"
msgid "option \"%s\" given bad argument \"%s\""
msgstr ""
#, c-format
msgctxt "STRING_MISSING_MALFORMED"
msgid "missing or malformed argument for option: %s"
msgstr ""
#, c-format
msgctxt "STRING_MUTING_TYPE"
msgid "messages of type \"%s\" will not be output"
msgstr ""
#, c-format
msgctxt "STRING_UNKNOWN_OPTION"
msgid "unknown option: %s"

View file

@ -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-10-07 16:24:04\n"
"PO-Revision-Date: 2017-10-10 08:20:36\n"
"Last-Translator: jderry\n"
"Language-Team: \n"
@ -1490,6 +1490,41 @@ msgstr ""
"classement. Si la valeur est <var>alpha</var>, l'algorithme est un classement alphabétique "
"ascendant. "
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteReports"
msgid ""
"Use this option to prevent Tidy from displaying certain types of "
"report output,for example, for conditions that you wish to ignore."
"<br/>"
"This option takes a list of one or more keys indicating the message "
"type to mute. You can discover these message keys by using the "
"<code>mute-id</code> configuration option and examining Tidy's "
"output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteShow"
msgid ""
"This option indicates whether or not Tidy should display message ID's "
"with each of its error reports. This could be useful if you wanted to "
"use the <code>mute</code> configuration option in order to filter "
"out certain report messages. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
@ -2919,11 +2954,21 @@ msgctxt "SPACE_PRECEDING_XMLDECL"
msgid "removing whitespace preceding XML Declaration"
msgstr "suppression de l'espace précédant la déclaration XML"
#, c-format
msgctxt "STRING_ARGUMENT_BAD"
msgid "option \"%s\" given bad argument \"%s\""
msgstr ""
#, c-format
msgctxt "STRING_MISSING_MALFORMED"
msgid "missing or malformed argument for option: %s"
msgstr "argument manquant ou incorrect pour l'option: %s"
#, c-format
msgctxt "STRING_MUTING_TYPE"
msgid "messages of type \"%s\" will not be output"
msgstr ""
#, c-format
msgctxt "STRING_UNKNOWN_OPTION"
msgid "unknown option: %s"

View file

@ -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-10-07 16:24:04\n"
"PO-Revision-Date: 2017-10-10 08:20:36\n"
"Last-Translator: jderry\n"
"Language-Team: \n"
@ -1544,6 +1544,41 @@ msgstr ""
"elemento usando o algoritmo de ordenação especificado. Se configurado para "
"<var>alpha</var>, o algoritmo é uma ordenação alfabética ascendente. "
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteReports"
msgid ""
"Use this option to prevent Tidy from displaying certain types of "
"report output,for example, for conditions that you wish to ignore."
"<br/>"
"This option takes a list of one or more keys indicating the message "
"type to mute. You can discover these message keys by using the "
"<code>mute-id</code> configuration option and examining Tidy's "
"output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteShow"
msgid ""
"This option indicates whether or not Tidy should display message ID's "
"with each of its error reports. This could be useful if you wanted to "
"use the <code>mute</code> configuration option in order to filter "
"out certain report messages. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
@ -3007,11 +3042,21 @@ msgctxt "SPACE_PRECEDING_XMLDECL"
msgid "removing whitespace preceding XML Declaration"
msgstr "removendo espaço em branco precedendo a declaração XML"
#, c-format
msgctxt "STRING_ARGUMENT_BAD"
msgid "option \"%s\" given bad argument \"%s\""
msgstr ""
#, c-format
msgctxt "STRING_MISSING_MALFORMED"
msgid "missing or malformed argument for option: %s"
msgstr "argumento faltando ou malformado para opção: %s"
#, c-format
msgctxt "STRING_MUTING_TYPE"
msgid "messages of type \"%s\" will not be output"
msgstr ""
#, c-format
msgctxt "STRING_UNKNOWN_OPTION"
msgid "unknown option: %s"

View file

@ -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-10-07 16:24:04\n"
"PO-Revision-Date: 2017-10-10 08:20:36\n"
"Last-Translator: jderry\n"
"Language-Team: \n"
@ -1255,6 +1255,41 @@ msgid ""
"been output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteReports"
msgid ""
"Use this option to prevent Tidy from displaying certain types of "
"report output,for example, for conditions that you wish to ignore."
"<br/>"
"This option takes a list of one or more keys indicating the message "
"type to mute. You can discover these message keys by using the "
"<code>mute-id</code> configuration option and examining Tidy's "
"output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteShow"
msgid ""
"This option indicates whether or not Tidy should display message ID's "
"with each of its error reports. This could be useful if you wanted to "
"use the <code>mute</code> configuration option in order to filter "
"out certain report messages. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
@ -2468,11 +2503,21 @@ msgctxt "SPACE_PRECEDING_XMLDECL"
msgid "removing whitespace preceding XML Declaration"
msgstr ""
#, c-format
msgctxt "STRING_ARGUMENT_BAD"
msgid "option \"%s\" given bad argument \"%s\""
msgstr ""
#, c-format
msgctxt "STRING_MISSING_MALFORMED"
msgid "missing or malformed argument for option: %s"
msgstr ""
#, c-format
msgctxt "STRING_MUTING_TYPE"
msgid "messages of type \"%s\" will not be output"
msgstr ""
#, c-format
msgctxt "STRING_UNKNOWN_OPTION"
msgid "unknown option: %s"

View file

@ -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-10-07 16:24:04\n"
"POT-Creation-Date: 2017-10-10 08:20:36\n"
"Last-Translator: jderry\n"
"Language-Team: \n"
@ -1255,6 +1255,41 @@ msgid ""
"been output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteReports"
msgid ""
"Use this option to prevent Tidy from displaying certain types of "
"report output,for example, for conditions that you wish to ignore."
"<br/>"
"This option takes a list of one or more keys indicating the message "
"type to mute. You can discover these message keys by using the "
"<code>mute-id</code> configuration option and examining Tidy's "
"output. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyMuteShow"
msgid ""
"This option indicates whether or not Tidy should display message ID's "
"with each of its error reports. This could be useful if you wanted to "
"use the <code>mute</code> configuration option in order to filter "
"out certain report messages. "
msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
@ -2470,11 +2505,21 @@ msgctxt "SPACE_PRECEDING_XMLDECL"
msgid "removing whitespace preceding XML Declaration"
msgstr ""
#, c-format
msgctxt "STRING_ARGUMENT_BAD"
msgid "option \"%s\" given bad argument \"%s\""
msgstr ""
#, c-format
msgctxt "STRING_MISSING_MALFORMED"
msgid "missing or malformed argument for option: %s"
msgstr ""
#, c-format
msgctxt "STRING_MUTING_TYPE"
msgid "messages of type \"%s\" will not be output"
msgstr ""
#, c-format
msgctxt "STRING_UNKNOWN_OPTION"
msgid "unknown option: %s"

View file

@ -781,6 +781,7 @@ void TY_(FreeAttrPriorityList)( TidyDocImpl* doc )
}
}
void TY_(DefinePriorityAttribute)(TidyDocImpl* doc, ctmbstr name)
{
enum { capacity = 10 };

View file

@ -249,6 +249,8 @@ static const TidyOptionImpl option_defs[] =
{ TidyShowWarnings, DD, "show-warnings", BL, yes, ParsePickList, &boolPicks },
{ TidySkipNested, MR, "skip-nested", BL, yes, ParsePickList, &boolPicks }, /* 1642186 - Issue #65 */
{ TidySortAttributes, PP, "sort-attributes", IN, TidySortAttrNone,ParsePickList, &sorterPicks },
{ TidyMuteReports, DD, "mute", ST, 0, ParseList, NULL },
{ TidyMuteShow, DD, "mute-id", BL, no, ParsePickList, &boolPicks },
{ TidyStrictTagsAttr, MR, "strict-tags-attributes", BL, no, ParsePickList, &boolPicks }, /* 20160209 - Issue #350 */
{ TidyStyleTags, MR, "fix-style-tags", BL, yes, ParsePickList, &boolPicks },
{ TidyTabSize, PP, "tab-size", IN, 8, ParseInt, NULL },
@ -302,7 +304,7 @@ static const struct {
/* forward declarations */
static void AdjustConfig( TidyDocImpl* doc );
static Bool GetPickListValue();
static Bool GetPickListValue( ctmbstr value, PickListItems* pickList, uint *result );
void TY_(InitConfig)( TidyDocImpl* doc )
@ -334,6 +336,7 @@ const TidyOptionImpl* TY_(lookupOption)( ctmbstr s )
return NULL;
}
const TidyOptionImpl* TY_(getOption)( TidyOptionId optId )
{
if ( optId < N_TIDY_OPTIONS )
@ -348,6 +351,7 @@ static void FreeOptionValue( TidyDocImpl* doc, const TidyOptionImpl* option, Tid
TidyDocFree( doc, value->p );
}
static void CopyOptionValue( TidyDocImpl* doc, const TidyOptionImpl* option,
TidyOptionValue* oldval, const TidyOptionValue* newval )
{
@ -406,6 +410,7 @@ Bool TY_(SetOptionBool)( TidyDocImpl* doc, TidyOptionId optId, Bool val )
return status;
}
static void GetOptionDefault( const TidyOptionImpl* option,
TidyOptionValue* dflt )
{
@ -415,6 +420,7 @@ static void GetOptionDefault( const TidyOptionImpl* option,
dflt->v = option->dflt;
}
static Bool OptionValueEqDefault( const TidyOptionImpl* option,
const TidyOptionValue* val )
{
@ -543,7 +549,7 @@ static Bool isOptionDeprecated( ctmbstr optName )
}
/* Aubstitute the new option for the deprecated one. */
/* Substitute the new option for the deprecated one. */
static Bool subDeprecatedOption( TidyDocImpl* doc, ctmbstr oldName, ctmbstr oldValue)
{
TidyOptionId newOptId = getOptionReplacement( oldName );
@ -566,7 +572,7 @@ static Bool subDeprecatedOption( TidyDocImpl* doc, ctmbstr oldName, ctmbstr oldV
uint value;
/* `show-body-only` used to use the autoBoolPicks */
if ( GetPickListValue( oldValue, autoBoolPicks, &value ) )
if ( GetPickListValue( oldValue, &autoBoolPicks, &value ) )
{
if ( value == TidyNoState )
{
@ -1165,12 +1171,14 @@ void AdjustConfig( TidyDocImpl* doc )
}
/* Coordinates Config update and Attributes data for priority attributes, as
a service to ParseList().
/* A service to ParseList(), keeps option values nicely formatted and
coordinates additions to the internal lists. Within Tidy, this function
might be used to programmatically add individual values to items that use
this service.
*/
void TY_(DeclarePriorityAttrib)( TidyDocImpl* doc, TidyOptionId optId, ctmbstr name )
void TY_(DeclareListItem)( TidyDocImpl* doc, const TidyOptionImpl* opt, ctmbstr name )
{
ctmbstr prvval = cfgStr( doc, optId );
ctmbstr prvval = cfgStr( doc, opt->id );
tmbstr catval = NULL;
ctmbstr theval = name;
if ( prvval )
@ -1182,14 +1190,27 @@ void TY_(DeclarePriorityAttrib)( TidyDocImpl* doc, TidyOptionId optId, ctmbstr n
theval = catval;
}
TY_(DefinePriorityAttribute)( doc, name );
SetOptionValue( doc, optId, theval );
switch ( opt->id )
{
case TidyPriorityAttributes:
TY_(DefinePriorityAttribute)( doc, name );
break;
case TidyMuteReports:
TY_(DefineMutedMessage)( doc, opt, name );
break;
default:
break;
}
SetOptionValue( doc, opt->id, theval );
if ( catval )
TidyDocFree( doc, catval );
}
}
/* a space or comma separated list of attribute names */
/* a space or comma separated list of items */
Bool ParseList( TidyDocImpl* doc, const TidyOptionImpl* option )
{
TidyConfigImpl* cfg = &doc->config;
@ -1235,15 +1256,7 @@ Bool ParseList( TidyDocImpl* doc, const TidyOptionImpl* option )
continue; /* there is a trailing space on the line. */
/* add attribute to array */
switch ( option->id )
{
case TidyPriorityAttributes:
TY_(DeclarePriorityAttrib)( doc, option->id, buf );
break;
default:
break;
}
TY_(DeclareListItem)( doc, option, buf );
i = 0;
++nItems;
@ -1251,15 +1264,7 @@ Bool ParseList( TidyDocImpl* doc, const TidyOptionImpl* option )
while ( c != EndOfStream );
if ( i > 0 )
switch ( option->id )
{
case TidyPriorityAttributes:
TY_(DeclarePriorityAttrib)( doc, option->id, buf );
break;
default:
break;
}
TY_(DeclareListItem)( doc, option, buf );
return ( nItems > 0 );
}

View file

@ -369,6 +369,12 @@ ctmbstr TY_(CharEncodingOptName)( int encoding );
void TY_(DeclareUserTag)( TidyDocImpl* doc, TidyOptionId optId,
uint tagType, ctmbstr name );
/** Coordinates Config update and list data.
** @param doc The Tidy document.
** @param opt The option the list item is intended for.
** @param name The name of the new list item.
*/
void TY_(DeclareListItem)( TidyDocImpl* doc, const TidyOptionImpl* opt, ctmbstr name );
#ifdef _DEBUG

View file

@ -1176,6 +1176,37 @@ static languageDefinition language_en = { whichPluralForm_en, {
"attribute sorting will take place after the priority attributes have "
"been output. "
},
{/* Important notes for translators:
- Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
<br/>.
- Entities, tags, attributes, etc., should be enclosed in <code></code>.
- Option values should be enclosed in <var></var>.
- It's very important that <br/> be self-closing!
- The strings "Tidy" and "HTML Tidy" are the program name and must not
be translated. */
TidyMuteReports, 0,
"Use this option to prevent Tidy from displaying certain types of "
"report output,for example, for conditions that you wish to ignore."
"<br/>"
"This option takes a list of one or more keys indicating the message "
"type to mute. You can discover these message keys by using the "
"<code>mute-id</code> configuration option and examining Tidy's "
"output. "
},
{/* Important notes for translators:
- Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
<br/>.
- Entities, tags, attributes, etc., should be enclosed in <code></code>.
- Option values should be enclosed in <var></var>.
- It's very important that <br/> be self-closing!
- The strings "Tidy" and "HTML Tidy" are the program name and must not
be translated. */
TidyMuteShow, 0,
"This option indicates whether or not Tidy should display message ID's "
"with each of its error reports. This could be useful if you wanted to "
"use the <code>mute</code> configuration option in order to filter "
"out certain report messages. "
},
{/* Important notes for translators:
- Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
<br/>.
@ -1918,7 +1949,9 @@ static languageDefinition language_en = { whichPluralForm_en, {
{ REPLACING_ELEMENT, 0, "replacing %s with %s" },
{ REPLACING_UNEX_ELEMENT, 0, "replacing unexpected %s with %s" },
{ SPACE_PRECEDING_XMLDECL, 0, "removing whitespace preceding XML Declaration" },
{ STRING_ARGUMENT_BAD, 0, "option \"%s\" given bad argument \"%s\"" },
{ STRING_MISSING_MALFORMED, 0, "missing or malformed argument for option: %s" },
{ STRING_MUTING_TYPE, 0, "messages of type \"%s\" will not be output" },
{ STRING_UNKNOWN_OPTION, 0, "unknown option: %s" },
{ SUSPECTED_MISSING_QUOTE, 0, "suspected missing quote mark for attribute value" },
{ TAG_NOT_ALLOWED_IN, 0, "%s isn't allowed in <%s> elements" },

View file

@ -153,6 +153,9 @@ static void messageOut( TidyMessageImpl *message )
break;
}
/* Suppress report messages if they've been muted. */
go = go & !message->muted;
/* Suppress report messages if we've already reached the reporting limit. */
if ( message->level <= TidyFatal )
{
@ -357,9 +360,11 @@ static struct _dispatchTable {
{ REPLACING_ELEMENT, TidyWarning, formatStandard },
{ REPLACING_UNEX_ELEMENT, TidyWarning, formatStandard },
{ SPACE_PRECEDING_XMLDECL, TidyWarning, formatStandard },
{ STRING_ARGUMENT_BAD, TidyConfig, formatStandard },
{ STRING_CONTENT_LOOKS, TidyInfo, formatStandard }, /* reportMarkupVersion() */
{ STRING_DOCTYPE_GIVEN, TidyInfo, formatStandard }, /* reportMarkupVersion() */
{ STRING_MISSING_MALFORMED, TidyConfig, formatStandard },
{ STRING_MUTING_TYPE, TidyConfig, formatStandard },
{ STRING_NO_SYSID, TidyInfo, formatStandard }, /* reportMarkupVersion() */
{ STRING_UNKNOWN_OPTION, TidyConfig, formatStandard },
{ SUSPECTED_MISSING_QUOTE, TidyWarning, formatStandard },
@ -723,6 +728,7 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
case STRING_CONTENT_LOOKS:
case STRING_DOCTYPE_GIVEN:
case STRING_MISSING_MALFORMED:
case STRING_MUTING_TYPE:
{
ctmbstr str;
if ( (str = va_arg( args, ctmbstr)) )
@ -760,6 +766,7 @@ TidyMessageImpl *formatStandard(TidyDocImpl* doc, Node *element, Node *node, uin
} break;
case OPTION_REMOVED_UNAPPLIED:
case STRING_ARGUMENT_BAD:
{
ctmbstr s1 = va_arg( args, ctmbstr );
ctmbstr s2 = va_arg( args, ctmbstr );
@ -1322,6 +1329,55 @@ void TY_(ReportNumWarnings)( TidyDocImpl* doc )
}
/*********************************************************************
* Message Muting
*********************************************************************/
void TY_(FreeMutedMessageList)( TidyDocImpl* doc )
{
TidyMutedMessages *list = &(doc->muted);
if ( list->list )
TidyFree( doc->allocator, list->list );
}
void TY_(DefineMutedMessage)(TidyDocImpl* doc, const TidyOptionImpl* opt, ctmbstr name)
{
enum { capacity = 10 };
TidyMutedMessages *list = &(doc->muted);
tidyStrings message = TY_(tidyErrorCodeFromKey)( name );
if ( message <= REPORT_MESSAGE_FIRST || message >= REPORT_MESSAGE_LAST)
{
TY_(Report)( doc, NULL, NULL, STRING_ARGUMENT_BAD, opt->name, name );
return;
}
if ( !list->list )
{
list->list = TidyAlloc(doc->allocator, sizeof(tidyStrings) * capacity );
list->list[0] = 0;
list->capacity = capacity;
list->count = 0;
}
if ( list->count >= list->capacity )
{
list->capacity = list->capacity * 2;
list->list = realloc( list->list, sizeof(tidyStrings) * list->capacity + 1 );
}
list->list[list->count] = message;
list->count++;
list->list[list->count] = 0;
/* Must come *after* adding to the list, in case it's muted, too. */
TY_(Report)( doc, NULL, NULL, STRING_MUTING_TYPE, name );
}
/*********************************************************************
* Key Discovery
*********************************************************************/
@ -1462,6 +1518,8 @@ static const TidyOptionId TidyIndentSpacesLinks[] = { TidyIndentContent, Tidy
static const TidyOptionId TidyInlineTagsLinks[] = { TidyBlockTags, TidyEmptyTags, TidyPreTags, TidyUseCustomTags, TidyUnknownOption };
static const TidyOptionId TidyMergeDivsLinks[] = { TidyMakeClean, TidyMergeSpans, TidyUnknownOption };
static const TidyOptionId TidyMergeSpansLinks[] = { TidyMakeClean, TidyMergeDivs, TidyUnknownOption };
static const TidyOptionId TidyMuteLinks[] = { TidyMuteShow };
static const TidyOptionId TidyMuteShowLinks[] = { TidyMuteReports };
static const TidyOptionId TidyNumEntitiesLinks[] = { TidyDoctype, TidyPreserveEntities, TidyUnknownOption };
static const TidyOptionId TidyOutCharEncodingLinks[] = { TidyCharEncoding, TidyUnknownOption };
static const TidyOptionId TidyOutFileLinks[] = { TidyErrFile, TidyUnknownOption };
@ -1490,11 +1548,13 @@ static const TidyOptionDoc docs_xrefs[] =
{ TidyInlineTags, TidyInlineTagsLinks },
{ TidyMergeDivs, TidyMergeDivsLinks },
{ TidyMergeSpans, TidyMergeSpansLinks },
{ TidyMuteShow, TidyMuteShowLinks },
{ TidyNumEntities, TidyNumEntitiesLinks },
{ TidyOutCharEncoding, TidyOutCharEncodingLinks },
{ TidyOutFile, TidyOutFileLinks },
{ TidyPreTags, TidyPreTagsLinks },
{ TidySortAttributes, TidySortAttributesLinks },
{ TidyMuteReports, TidyMuteLinks },
{ TidyUseCustomTags, TidyUseCustomTagsLinks },
{ TidyWrapAttVals, TidyWrapAttValsLinks },
{ TidyWrapScriptlets, TidyWrapScriptletsLinks },

View file

@ -46,6 +46,7 @@
******************************************************************************/
#include "forward.h"
#include "config.h"
/** @addtogroup internal_api */
/** @{ */
@ -180,6 +181,39 @@ void TY_(ReportNumWarnings)( TidyDocImpl* doc );
/** @} message_reporting group */
/***************************************************************************//**
** @defgroup message_mutinging Message Muting
**
** Message types included in the `mute` option will be be printed in
** messageOut().
**
** @{
******************************************************************************/
/** Maintains a list of messages not to display. */
typedef struct _mutedMessages {
tidyStrings* list; /**< A list of messages that won't be output. */
uint count; /**< Current count of the list. */
uint capacity; /**< Current capacity of the list. */
} TidyMutedMessages;
/** Frees the list of muted messages.
** @param doc The Tidy document.
*/
void TY_(FreeMutedMessageList)( TidyDocImpl* doc );
/** Adds a new message ID to the list of muted messages.
** @param doc The Tidy document.
** @param name The message code as a string.
*/
void TY_(DefineMutedMessage)( TidyDocImpl* doc, const TidyOptionImpl* opt, ctmbstr name );
/** @} */
/** @} message_muting group */
/***************************************************************************//**
** @defgroup message_keydiscovery Key Discovery
**

View file

@ -85,6 +85,8 @@ static TidyMessageImpl *tidyMessageCreateInitV( TidyDocImpl *doc,
va_list args_copy;
enum { sizeMessageBuf=2048 };
ctmbstr pattern;
uint i = 0;
/* Things we know... */
@ -137,7 +139,7 @@ static TidyMessageImpl *tidyMessageCreateInitV( TidyDocImpl *doc,
result->messagePrefix = tidyLocalizedString(level);
if ( line > 0 && column > 0 )
pattern = "%s%s%s"; /* pattern in there's location information */
pattern = "%s%s%s"; /* pattern if there's location information */
else
pattern = "%.0s%s%s"; /* otherwise if there isn't */
@ -154,6 +156,11 @@ static TidyMessageImpl *tidyMessageCreateInitV( TidyDocImpl *doc,
result->messagePos, result->messagePrefix,
result->message);
if ( ( cfgBool(doc, TidyMuteShow) == yes ) && level <= TidyFatal )
{
TY_(tmbsnprintf)(result->messageOutputDefault, sizeMessageBuf, "%s (%s)", result->messageOutputDefault, TY_(tidyErrorCodeAsKey)(code) );
TY_(tmbsnprintf)(result->messageOutput, sizeMessageBuf, "%s (%s)", result->messageOutput, TY_(tidyErrorCodeAsKey)(code) );
}
result->allowMessage = yes;
@ -184,6 +191,19 @@ static TidyMessageImpl *tidyMessageCreateInitV( TidyDocImpl *doc,
result->allowMessage = result->allowMessage & doc->messageCallback( tidyImplToMessage(result) );
}
/* finally, check the document's configuration to determine whether
this message is muted. */
result->muted = no;
while ( ( doc->muted.list ) && ( doc->muted.list[i] != 0 ) )
{
if ( doc->muted.list[i] == code )
{
result->muted = yes;
break;
}
i++;
}
return result;
}
@ -292,6 +312,11 @@ TidyReportLevel TY_(getMessageLevel)( TidyMessageImpl message )
return message.level;
}
Bool TY_(getMessageIsMuted)( TidyMessageImpl message )
{
return message.muted;
}
ctmbstr TY_(getMessageFormatDefault)( TidyMessageImpl message )
{
return message.messageFormatDefault;

View file

@ -80,6 +80,9 @@ int TY_(getMessageColumn)( TidyMessageImpl message );
/** get the TidyReportLevel of the message. */
TidyReportLevel TY_(getMessageLevel)( TidyMessageImpl message );
/** get whether or not the message was muted by the configuration. */
Bool TY_(getMessageIsMuted)( TidyMessageImpl message );
/** the built-in format string */
ctmbstr TY_(getMessageFormatDefault)( TidyMessageImpl message );

View file

@ -15,6 +15,7 @@
#include "attrs.h"
#include "pprint.h"
#include "access.h"
#include "message.h"
#ifndef MAX
#define MAX(a,b) (((a) > (b))?(a):(b))
@ -40,10 +41,11 @@ struct _TidyDocImpl
Lexer* lexer;
/* Config + Markup Declarations */
TidyConfigImpl config;
TidyTagImpl tags;
TidyAttribImpl attribs;
TidyAccessImpl access;
TidyConfigImpl config;
TidyTagImpl tags;
TidyAttribImpl attribs;
TidyAccessImpl access;
TidyMutedMessages muted;
/* The Pretty Print buffer */
TidyPrintImpl pprint;
@ -104,6 +106,7 @@ struct _TidyMessageImpl
int column; /* the column the message applies to */
TidyReportLevel level; /* the severity level of the message */
Bool allowMessage; /* indicates whether or not a filter rejected a message */
Bool muted; /* indicates whether or not a configuration mutes this message */
int argcount; /* the number of arguments */
struct printfArg* arguments; /* the arguments' values and types */

View file

@ -139,6 +139,7 @@ void tidyDocRelease( TidyDocImpl* doc )
TY_(FreeConfig)( doc );
TY_(FreeAttrTable)( doc );
TY_(FreeAttrPriorityList)( doc );
TY_(FreeMutedMessageList( doc ));
TY_(FreeTags)( doc );
/*\
* Issue #186 - Now FreeNode depend on the doctype, so the lexer is needed
@ -723,7 +724,11 @@ TidyReportLevel TIDY_CALL tidyGetMessageLevel( TidyMessage tmessage )
return TY_(getMessageLevel)(*message);
}
Bool TIDY_CALL tidyGetMessageIsMuted( TidyMessage tmessage )
{
TidyMessageImpl *message = tidyMessageToImpl(tmessage);
return TY_(getMessageIsMuted)(*message);
}
ctmbstr TIDY_CALL tidyGetMessageFormatDefault( TidyMessage tmessage )
{