Adds message squelching (muting) to Tidy, avoiding the need to specify a new

option every time we might want to allow or disallow new output. Adds two new
options:
  - `squelch-id` (default **no**) will provide tags during Tidy's output that
    can be used to silence warnings. For example, `MISSING_ENDTAG_OPTIONAL`
    will be shown after warnings of that type. Then in the future, the user can
    use...
  - `squelch` (default NULL) takes a list of message identification tags.
    Messages of this tag type will then be muted from output.

This gives the user great control over hiding things that he or she doesn't care
about seeing. However, muted errors/warnings still count toward error summaries.

If we merge this, then TidyShowMetaChange and TidyWarnPropAttrs are candidates
for removal (using the deprecation mechanism Tidy now has, these will continue
to work, though).
This commit is contained in:
Jim Derry 2017-10-08 10:47:03 -04:00
parent 5e66816380
commit 626375346d
17 changed files with 504 additions and 39 deletions

View file

@ -255,7 +255,9 @@ extern "C" {
FN(REPLACING_ELEMENT) \
FN(REPLACING_UNEX_ELEMENT) \
FN(SPACE_PRECEDING_XMLDECL) \
FN(STRING_ARGUMENT_BAD) \
FN(STRING_MISSING_MALFORMED) \
FN(STRING_SQUELCHING_TYPE) \
FN(STRING_UNKNOWN_OPTION) \
FN(SUSPECTED_MISSING_QUOTE) \
FN(TAG_NOT_ALLOWED_IN) \
@ -636,6 +638,7 @@ typedef enum
TidyShowWarnings, /**< However errors are always shown */
TidySkipNested, /**< Skip nested tags in script and style CDATA */
TidySortAttributes, /**< Sort attributes */
TidySquelchReports, /**< Filter these messages from output. */
TidySquelchShow, /**< Show message ID's in the error table */
TidyStrictTagsAttr, /**< Ensure tags and attributes match output HTML version */
TidyStyleTags, /**< Move sytle to head */
@ -1415,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-08 10:46:33\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 "TidySquelchReports"
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 squelch. You can discover these message keys by using the "
"<code>squelch-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 "TidySquelchShow"
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>squelch</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_SQUELCHING_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-08 10:46:33\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 "TidySquelchReports"
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 squelch. You can discover these message keys by using the "
"<code>squelch-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 "TidySquelchShow"
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>squelch</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_SQUELCHING_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-08 10:46:33\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 "TidySquelchReports"
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 squelch. You can discover these message keys by using the "
"<code>squelch-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 "TidySquelchShow"
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>squelch</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_SQUELCHING_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-08 10:46:33\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 "TidySquelchReports"
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 squelch. You can discover these message keys by using the "
"<code>squelch-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 "TidySquelchShow"
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>squelch</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_SQUELCHING_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-08 10:46:33\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 "TidySquelchReports"
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 squelch. You can discover these message keys by using the "
"<code>squelch-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 "TidySquelchShow"
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>squelch</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_SQUELCHING_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-08 10:46:33\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 "TidySquelchReports"
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 squelch. You can discover these message keys by using the "
"<code>squelch-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 "TidySquelchShow"
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>squelch</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_SQUELCHING_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-08 10:46:33\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 "TidySquelchReports"
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 squelch. You can discover these message keys by using the "
"<code>squelch-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 "TidySquelchShow"
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>squelch</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_SQUELCHING_TYPE"
msgid "messages of type \"%s\" will not be output"
msgstr ""
#, c-format
msgctxt "STRING_UNKNOWN_OPTION"
msgid "unknown option: %s"

View file

@ -249,6 +249,7 @@ 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 },
{ TidySquelchReports, DD, "squelch", ST, 0, ParseList, NULL },
{ TidySquelchShow, DD, "squelch-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 },
@ -1166,12 +1167,16 @@ 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.
@todo: see if we can apply this for other things such as tags, etc., to
simplify code.
*/
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 )
@ -1183,14 +1188,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 TidySquelchReports:
TY_(DefineSquelchedMessage)( 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;
@ -1236,15 +1254,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;
@ -1252,15 +1262,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,23 @@ 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. */
TidySquelchReports, 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 squelch. You can discover these message keys by using the "
"<code>squelch-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/>.
@ -1187,8 +1204,8 @@ static languageDefinition language_en = { whichPluralForm_en, {
TidySquelchShow, 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 \"squelch\" configuration option in order to filter out certain "
"report messages. "
"use the <code>squelch</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
@ -1932,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_SQUELCHING_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 squelched. */
go = go & !message->squelched;
/* Suppress report messages if we've already reached the reporting limit. */
if ( message->level <= TidyFatal )
{
@ -357,10 +360,12 @@ 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_NO_SYSID, TidyInfo, formatStandard }, /* reportMarkupVersion() */
{ STRING_SQUELCHING_TYPE, TidyConfig, formatStandard },
{ STRING_UNKNOWN_OPTION, TidyConfig, formatStandard },
{ SUSPECTED_MISSING_QUOTE, TidyWarning, formatStandard },
{ TAG_NOT_ALLOWED_IN, TidyWarning, formatStandard, PREVIOUS_LOCATION },
@ -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_SQUELCHING_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,52 @@ void TY_(ReportNumWarnings)( TidyDocImpl* doc )
}
/*********************************************************************
* Message Squelching
*********************************************************************/
void TY_(FreeSquelchedMessageList)( TidyDocImpl* doc )
{
TidySquelchedMessages *list = &(doc->squelched);
if ( list->list )
TidyFree( doc->allocator, list->list );
}
void TY_(DefineSquelchedMessage)(TidyDocImpl* doc, const TidyOptionImpl* opt, ctmbstr name)
{
enum { capacity = 10 };
TidySquelchedMessages *list = &(doc->squelched);
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 );
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 squelched, too. */
TY_(Report)( doc, NULL, NULL, STRING_SQUELCHING_TYPE, name );
}
/*********************************************************************
* Key Discovery
*********************************************************************/
@ -1467,6 +1520,8 @@ static const TidyOptionId TidyOutCharEncodingLinks[] = { TidyCharEncoding, TidyU
static const TidyOptionId TidyOutFileLinks[] = { TidyErrFile, TidyUnknownOption };
static const TidyOptionId TidyPreTagsLinks[] = { TidyBlockTags, TidyEmptyTags, TidyInlineTags, TidyUseCustomTags, TidyUnknownOption };
static const TidyOptionId TidySortAttributesLinks[] = { TidyPriorityAttributes, TidyUnknownOption };
static const TidyOptionId TidySquelchLinks[] = { TidySquelchShow };
static const TidyOptionId TidySquelchShowLinks[] = { TidySquelchReports };
static const TidyOptionId TidyUseCustomTagsLinks[] = { TidyBlockTags, TidyEmptyTags, TidyInlineTags, TidyPreTags, TidyUnknownOption };
static const TidyOptionId TidyWrapAttValsLinks[] = { TidyWrapScriptlets, TidyLiteralAttribs, TidyUnknownOption };
static const TidyOptionId TidyWrapScriptletsLinks[] = { TidyWrapAttVals, TidyUnknownOption };
@ -1495,6 +1550,8 @@ static const TidyOptionDoc docs_xrefs[] =
{ TidyOutFile, TidyOutFileLinks },
{ TidyPreTags, TidyPreTagsLinks },
{ TidySortAttributes, TidySortAttributesLinks },
{ TidySquelchShow, TidySquelchShowLinks },
{ TidySquelchReports, TidySquelchLinks },
{ 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_squelching Message Squelching
**
** Message types included in the `squelch` option will be be printed in
** messageOut().
**
** @{
******************************************************************************/
/** Maintains a list of messages not to display. */
typedef struct _squelchedMessages {
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. */
} TidySquelchedMessages;
/** Frees the list of squelched messages.
** @param doc The Tidy document.
*/
void TY_(FreeSquelchedMessageList)( TidyDocImpl* doc );
/** Adds a new message ID to the list of squelched messages.
** @param doc The Tidy document.
** @param name The message code as a string.
*/
void TY_(DefineSquelchedMessage)( TidyDocImpl* doc, const TidyOptionImpl* opt, ctmbstr name );
/** @} */
/** @} message_squelching 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... */
@ -189,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 squelched. */
result->squelched = no;
while ( ( doc->squelched.list ) && ( doc->squelched.list[i] != 0 ) )
{
if ( doc->squelched.list[i] == code )
{
result->squelched = yes;
break;
}
i++;
}
return result;
}
@ -297,6 +312,11 @@ TidyReportLevel TY_(getMessageLevel)( TidyMessageImpl message )
return message.level;
}
Bool TY_(getMessageIsSquelched)( TidyMessageImpl message )
{
return message.squelched;
}
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 squelched by the configuration. */
Bool TY_(getMessageIsSquelched)( 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;
TidySquelchedMessages squelched;
/* 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 squelched; /* indicates whether or not a configuration squelches 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_(FreeSquelchedMessageList( doc ));
TY_(FreeTags)( doc );
/*\
* Issue #186 - Now FreeNode depend on the doctype, so the lexer is needed