Add a xml-error-strings service to console app providing symbols developers can use with TidyErrorFilter3.

This commit is contained in:
Jim Derry 2016-02-17 12:35:20 +08:00
parent bc1e54d5b5
commit cc59efb23d
3 changed files with 47 additions and 2 deletions

View file

@ -283,6 +283,7 @@ static const CmdOptDesc cmdopt_defs[] = {
{ CmdOptXML, "-xml-help", TC_OPT_XMLHELP, 0, NULL }, { CmdOptXML, "-xml-help", TC_OPT_XMLHELP, 0, NULL },
{ CmdOptXML, "-xml-config", TC_OPT_XMLCFG, 0, NULL }, { CmdOptXML, "-xml-config", TC_OPT_XMLCFG, 0, NULL },
{ CmdOptXML, "-xml-strings", TC_OPT_XMLSTRG, 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 }, { CmdOptXML, "-xml-options-strings", TC_OPT_XMLOPTS, 0, NULL },
{ CmdOptMisc, NULL, 0, 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. ** 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 ** that option description strings as represented on screen output are
** correct and do not break tidy. ** 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( "<?xml version=\"1.0\"?>\n" );
printf( "<error_strings version=\"%s\">\n", tidyLibraryVersion());
while (j) {
item = getNextErrorCode(&j);
localizedString = tidyLocalizedString(item->value);
printf( " <error_string>\n" );
printf( " <name>%s</name>\n",item->key);
if ( localizedString )
printf( " <string class=\"%s\"><[CDATA[%s]]></string>\n", tidyGetLanguage(), localizedString );
else
printf( " <string class=\"%s\">NULL</string>\n", tidyGetLanguage() );
printf( " </error_string>\n" );
}
printf( "</error_strings>\n" );
}
/** /**
** Handles the -xml-strings service. ** Handles the -xml-strings service.
** This service was primarily helpful to developers and localizers to ** This service was primarily helpful to developers and localizers to
@ -1685,6 +1721,12 @@ int main( int argc, char** argv )
tidyRelease( tdoc ); tidyRelease( tdoc );
return 0; /* success */ 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) else if ( strcasecmp(arg, "xml-options-strings") == 0)
{ {
xml_options_strings( tdoc ); xml_options_strings( tdoc );

View file

@ -163,6 +163,7 @@ typedef enum
TC_OPT_XML, TC_OPT_XML,
TC_OPT_XMLCFG, TC_OPT_XMLCFG,
TC_OPT_XMLSTRG, TC_OPT_XMLSTRG,
TC_OPT_XMLERRS,
TC_OPT_XMLOPTS, TC_OPT_XMLOPTS,
TC_OPT_XMLHELP, TC_OPT_XMLHELP,
TC_STRING_CONF_HEADER, TC_STRING_CONF_HEADER,

View file

@ -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_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:" }, { TC_STRING_CONF_HEADER, 0, "Configuration File Settings:" },