From cc59efb23d07e79dca7f59781f230ca9a4d29d55 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Wed, 17 Feb 2016 12:35:20 +0800 Subject: [PATCH] Add a `xml-error-strings` service to console app providing symbols developers can use with TidyErrorFilter3. --- console/tidy.c | 44 +++++++++++++++++++++++++++++++++++++++++++- src/language.h | 1 + src/language_en.h | 4 +++- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/console/tidy.c b/console/tidy.c index 5e70064..4a0f0be 100644 --- a/console/tidy.c +++ b/console/tidy.c @@ -283,6 +283,7 @@ static const CmdOptDesc cmdopt_defs[] = { { CmdOptXML, "-xml-help", TC_OPT_XMLHELP, 0, NULL }, { CmdOptXML, "-xml-config", TC_OPT_XMLCFG, 0, NULL }, { CmdOptXML, "-xml-strings", TC_OPT_XMLSTRG, 0, NULL }, + { CmdOptXML, "-xml-error-strings", TC_OPT_XMLERRS, 0, NULL }, { CmdOptXML, "-xml-options-strings", TC_OPT_XMLOPTS, 0, NULL }, { CmdOptMisc, NULL, 0, 0, NULL } }; @@ -1408,7 +1409,7 @@ static void printXMLOptionString( TidyDoc tdoc, TidyOption topt, OptionDesc *d ) /** ** Handles the -xml-options-strings service. - ** This service is primarily helppful to developers and localizers to test + ** This service is primarily helpful to developers and localizers to test ** that option description strings as represented on screen output are ** correct and do not break tidy. **/ @@ -1421,6 +1422,41 @@ static void xml_options_strings( TidyDoc tdoc ) } +/** + ** Handles the -xml-error-strings service. + ** This service is primarily helpful to developers who need to generate + ** an updated list of strings to expect when using `TidyReportFilter3`. + ** Included in the output is the current string associated with the error + ** symbol. + **/ +static void xml_error_strings( TidyDoc tdoc ) +{ + const tidyErrorFilterKeyItem *item; + ctmbstr localizedString; + TidyIterator j = getErrorCodeList(); + + printf( "\n" ); + printf( "\n", tidyLibraryVersion()); + + while (j) { + item = getNextErrorCode(&j); + localizedString = tidyLocalizedString(item->value); + printf( " \n" ); + printf( " %s\n",item->key); + if ( localizedString ) + printf( " <[CDATA[%s]]>\n", tidyGetLanguage(), localizedString ); + else + printf( " NULL\n", tidyGetLanguage() ); + + printf( " \n" ); + } + + printf( "\n" ); +} + + + + /** ** Handles the -xml-strings service. ** This service was primarily helpful to developers and localizers to @@ -1685,6 +1721,12 @@ int main( int argc, char** argv ) tidyRelease( tdoc ); return 0; /* success */ } + else if ( strcasecmp(arg, "xml-error-strings") == 0) + { + xml_error_strings( tdoc ); + tidyRelease( tdoc ); + return 0; /* success */ + } else if ( strcasecmp(arg, "xml-options-strings") == 0) { xml_options_strings( tdoc ); diff --git a/src/language.h b/src/language.h index 6e78582..7b900a7 100644 --- a/src/language.h +++ b/src/language.h @@ -163,6 +163,7 @@ typedef enum TC_OPT_XML, TC_OPT_XMLCFG, TC_OPT_XMLSTRG, + TC_OPT_XMLERRS, TC_OPT_XMLOPTS, TC_OPT_XMLHELP, TC_STRING_CONF_HEADER, diff --git a/src/language_en.h b/src/language_en.h index a06d58c..1421bbd 100644 --- a/src/language_en.h +++ b/src/language_en.h @@ -1675,7 +1675,9 @@ static languageDefinition language_en = { whichPluralForm_en, { TC_OPT_XMLSTRG, 0, "output all of Tidy's strings in XML format" }, - { TC_OPT_XMLOPTS, 0, "output all option descriptions cleaned XML format" }, + { TC_OPT_XMLERRS, 0, "output error constants and strings in XML format" }, + + { TC_OPT_XMLOPTS, 0, "output option descriptions in XML format" }, { TC_STRING_CONF_HEADER, 0, "Configuration File Settings:" },