From ab8a4249df9ed9260fc4a017c5ef3d33d5c55ec1 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Sat, 7 Oct 2017 18:10:46 -0400 Subject: [PATCH] Added `squelch-id` (TidySquelchShow) so that message ID's will be displayed in the report output table. This can be used to show message ID's that the user can use to filter against in the upcoming `squelch` option. --- include/tidyenum.h | 1 + src/config.c | 1 + src/language_en.h | 14 ++++++++++++++ src/messageobj.c | 7 ++++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/include/tidyenum.h b/include/tidyenum.h index 44f730b..e9e9873 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -636,6 +636,7 @@ typedef enum TidyShowWarnings, /**< However errors are always shown */ TidySkipNested, /**< Skip nested tags in script and style CDATA */ TidySortAttributes, /**< Sort attributes */ + TidySquelchShow, /**< 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 */ diff --git a/src/config.c b/src/config.c index df3b558..1c2f4c7 100644 --- a/src/config.c +++ b/src/config.c @@ -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 }, + { 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 }, { TidyTabSize, PP, "tab-size", IN, 8, ParseInt, NULL }, diff --git a/src/language_en.h b/src/language_en.h index 7a6c3ae..3d93903 100644 --- a/src/language_en.h +++ b/src/language_en.h @@ -1176,6 +1176,20 @@ static languageDefinition language_en = { whichPluralForm_en, { "attribute sorting will take place after the priority attributes have " "been output. " }, + {/* Important notes for translators: + - Use only , , , , and +
. + - Entities, tags, attributes, etc., should be enclosed in . + - Option values should be enclosed in . + - It's very important that
be self-closing! + - The strings "Tidy" and "HTML Tidy" are the program name and must not + be translated. */ + 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. " + }, {/* Important notes for translators: - Use only , , , , and
. diff --git a/src/messageobj.c b/src/messageobj.c index ffdb916..e2fa8e9 100644 --- a/src/messageobj.c +++ b/src/messageobj.c @@ -137,7 +137,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 +154,11 @@ static TidyMessageImpl *tidyMessageCreateInitV( TidyDocImpl *doc, result->messagePos, result->messagePrefix, result->message); + if ( cfgBool(doc, TidySquelchShow) == yes ) + { + 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;