Added -export-config and -export-default-config so that users can generate a
starting config style with every option, suitable for rc files.
This commit is contained in:
parent
393fdfda3f
commit
9c6a1e47ae
|
@ -390,6 +390,8 @@ static const CmdOptDesc cmdopt_defs[] = {
|
|||
{ CmdOptMisc, "-help-config", TC_OPT_HELPCFG, 0, NULL },
|
||||
{ CmdOptMisc, "-help-env", TC_OPT_HELPENV, 0, NULL },
|
||||
{ CmdOptMisc, "-show-config", TC_OPT_SHOWCFG, 0, NULL },
|
||||
{ CmdOptMisc, "-export-config", TC_OPT_EXP_CFG, 0, NULL },
|
||||
{ CmdOptMisc, "-export-default-config", TC_OPT_EXP_DEF, 0, NULL },
|
||||
{ CmdOptMisc, "-help-option <%s>", TC_OPT_HELPOPT, TC_LABEL_OPT, NULL },
|
||||
{ CmdOptMisc, "-language <%s>", TC_OPT_LANGUAGE, TC_LABEL_LANG, "language: <%s>" },
|
||||
{ CmdOptXML, "-xml-help", TC_OPT_XMLHELP, 0, NULL },
|
||||
|
@ -1498,6 +1500,78 @@ static void optionvalues( TidyDoc tdoc )
|
|||
|
||||
|
||||
/** @} end service_show_config group */
|
||||
/* MARK: - Provide the -export-config Services */
|
||||
/***************************************************************************//**
|
||||
** @defgroup service_export_config Provide the -export-config Services
|
||||
*******************************************************************************
|
||||
** @{
|
||||
*/
|
||||
|
||||
|
||||
/** Prints the option value for a given option.
|
||||
*/
|
||||
static void printOptionExportValues(TidyDoc ARG_UNUSED(tdoc), /**< The Tidy document. */
|
||||
TidyOption topt, /**< The option for which to show values. */
|
||||
OptionDesc *d /**< The OptionDesc array. */
|
||||
)
|
||||
{
|
||||
TidyOptionId optId = tidyOptGetId( topt );
|
||||
|
||||
if ( tidyOptGetCategory(topt) == TidyInternalCategory )
|
||||
return;
|
||||
|
||||
switch ( optId )
|
||||
{
|
||||
case TidyInlineTags:
|
||||
case TidyBlockTags:
|
||||
case TidyEmptyTags:
|
||||
case TidyPreTags:
|
||||
{
|
||||
TidyIterator pos = tidyOptGetDeclTagList( tdoc );
|
||||
while ( pos )
|
||||
{
|
||||
d->def = tidyOptGetNextDeclTag(tdoc, optId, &pos);
|
||||
if ( pos )
|
||||
{
|
||||
printf( "%s: %s\n", d->name, d->def );
|
||||
d->name = "";
|
||||
d->type = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* fix for http://tidy.sf.net/bug/873921 */
|
||||
if ( *d->name || *d->type || (d->def && *d->def) )
|
||||
{
|
||||
if ( ! d->def )
|
||||
d->def = "";
|
||||
printf( "%s: %s\n", d->name, d->def );
|
||||
}
|
||||
}
|
||||
|
||||
/** Handles the -export-config service.
|
||||
** @param tdoc The Tidy Document.
|
||||
*/
|
||||
static void exportOptionValues( TidyDoc tdoc )
|
||||
{
|
||||
ForEachSortedOption( tdoc, printOptionExportValues );
|
||||
}
|
||||
|
||||
/** Handles the -export-default-config service.
|
||||
** @param tdoc The Tidy Document.
|
||||
*/
|
||||
static void exportDefaultOptionValues( TidyDoc tdoc )
|
||||
{
|
||||
tidyOptResetAllToDefault( tdoc );
|
||||
ForEachSortedOption( tdoc, printOptionExportValues );
|
||||
}
|
||||
|
||||
|
||||
/** @} end service_export_config group */
|
||||
/* MARK: - Provide the -version Service */
|
||||
/***************************************************************************//**
|
||||
** @defgroup service_version Provide the -version Service
|
||||
|
@ -2194,6 +2268,18 @@ int main( int argc, char** argv )
|
|||
tidyRelease( tdoc );
|
||||
return 0; /* success */
|
||||
}
|
||||
else if ( strcasecmp(arg, "export-config") == 0 )
|
||||
{
|
||||
exportOptionValues( tdoc );
|
||||
tidyRelease( tdoc );
|
||||
return 0; /* success */
|
||||
}
|
||||
else if ( strcasecmp(arg, "export-default-config") == 0 )
|
||||
{
|
||||
exportDefaultOptionValues( tdoc );
|
||||
tidyRelease( tdoc );
|
||||
return 0; /* success */
|
||||
}
|
||||
else if ( strcasecmp(arg, "config") == 0 )
|
||||
{
|
||||
if ( argc >= 3 )
|
||||
|
|
|
@ -449,6 +449,8 @@ extern "C" {
|
|||
FN(TC_OPT_RAW) \
|
||||
FN(TC_OPT_SHIFTJIS) \
|
||||
FN(TC_OPT_SHOWCFG) \
|
||||
FN(TC_OPT_EXP_CFG) \
|
||||
FN(TC_OPT_EXP_DEF) \
|
||||
FN(TC_OPT_UPPER) \
|
||||
FN(TC_OPT_UTF16) \
|
||||
FN(TC_OPT_UTF16BE) \
|
||||
|
|
|
@ -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-01 19:19:32\n"
|
||||
"POT-Creation-Date: 2017-10-01 19:49:27\n"
|
||||
"Last-Translator: jderry\n"
|
||||
"Language-Team: \n"
|
||||
|
||||
|
@ -3213,6 +3213,14 @@ msgctxt "TC_OPT_SHOWCFG"
|
|||
msgid "list the current configuration settings"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "TC_OPT_EXP_CFG"
|
||||
msgid "list the current configuration settings, suitable for a config file"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "TC_OPT_EXP_DEF"
|
||||
msgid "list the default configuration settings, suitable for a config file"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "TC_OPT_UPPER"
|
||||
msgid "force tags to upper case"
|
||||
msgstr ""
|
||||
|
|
|
@ -2132,6 +2132,8 @@ static languageDefinition language_en = { whichPluralForm_en, {
|
|||
{ TC_OPT_RAW, 0, "output values above 127 without conversion to entities" },
|
||||
{ TC_OPT_SHIFTJIS, 0, "use Shift_JIS for both input and output" },
|
||||
{ TC_OPT_SHOWCFG, 0, "list the current configuration settings" },
|
||||
{ TC_OPT_EXP_CFG, 0, "list the current configuration settings, suitable for a config file" },
|
||||
{ TC_OPT_EXP_DEF, 0, "list the default configuration settings, suitable for a config file" },
|
||||
{ TC_OPT_UPPER, 0, "force tags to upper case" },
|
||||
{ TC_OPT_UTF16, 0, "use UTF-16 for both input and output" },
|
||||
{ TC_OPT_UTF16BE, 0, "use UTF-16BE for both input and output" },
|
||||
|
|
Loading…
Reference in a new issue