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
174
console/tidy.c
174
console/tidy.c
|
@ -345,58 +345,60 @@ typedef struct {
|
|||
** specified by the subKey field.
|
||||
*/
|
||||
static const CmdOptDesc cmdopt_defs[] = {
|
||||
{ CmdOptFileManip, "-output <%s>", TC_OPT_OUTPUT, TC_LABEL_FILE, "output-file: <%s>", "-o <%s>" },
|
||||
{ CmdOptFileManip, "-config <%s>", TC_OPT_CONFIG, TC_LABEL_FILE, NULL },
|
||||
{ CmdOptFileManip, "-file <%s>", TC_OPT_FILE, TC_LABEL_FILE, "error-file: <%s>", "-f <%s>" },
|
||||
{ CmdOptFileManip, "-modify", TC_OPT_MODIFY, 0, "write-back: yes", "-m" },
|
||||
{ CmdOptProcDir, "-indent", TC_OPT_INDENT, 0, "indent: auto", "-i" },
|
||||
{ CmdOptProcDir, "-wrap <%s>", TC_OPT_WRAP, TC_LABEL_COL, "wrap: <%s>", "-w <%s>" },
|
||||
{ CmdOptProcDir, "-upper", TC_OPT_UPPER, 0, "uppercase-tags: yes", "-u" },
|
||||
{ CmdOptProcDir, "-clean", TC_OPT_CLEAN, 0, "clean: yes", "-c" },
|
||||
{ CmdOptProcDir, "-bare", TC_OPT_BARE, 0, "bare: yes", "-b" },
|
||||
{ CmdOptProcDir, "-gdoc", TC_OPT_GDOC, 0, "gdoc: yes", "-g" },
|
||||
{ CmdOptProcDir, "-numeric", TC_OPT_NUMERIC, 0, "numeric-entities: yes", "-n" },
|
||||
{ CmdOptProcDir, "-errors", TC_OPT_ERRORS, 0, "markup: no", "-e" },
|
||||
{ CmdOptProcDir, "-quiet", TC_OPT_QUIET, 0, "quiet: yes", "-q" },
|
||||
{ CmdOptProcDir, "-omit", TC_OPT_OMIT, 0, "omit-optional-tags: yes" },
|
||||
{ CmdOptProcDir, "-xml", TC_OPT_XML, 0, "input-xml: yes" },
|
||||
{ CmdOptProcDir, "-asxml", TC_OPT_ASXML, 0, "output-xhtml: yes", "-asxhtml" },
|
||||
{ CmdOptProcDir, "-ashtml", TC_OPT_ASHTML, 0, "output-html: yes" },
|
||||
{ CmdOptFileManip, "-output <%s>", TC_OPT_OUTPUT, TC_LABEL_FILE, "output-file: <%s>", "-o <%s>" },
|
||||
{ CmdOptFileManip, "-config <%s>", TC_OPT_CONFIG, TC_LABEL_FILE, NULL },
|
||||
{ CmdOptFileManip, "-file <%s>", TC_OPT_FILE, TC_LABEL_FILE, "error-file: <%s>", "-f <%s>" },
|
||||
{ CmdOptFileManip, "-modify", TC_OPT_MODIFY, 0, "write-back: yes", "-m" },
|
||||
{ CmdOptProcDir, "-indent", TC_OPT_INDENT, 0, "indent: auto", "-i" },
|
||||
{ CmdOptProcDir, "-wrap <%s>", TC_OPT_WRAP, TC_LABEL_COL, "wrap: <%s>", "-w <%s>" },
|
||||
{ CmdOptProcDir, "-upper", TC_OPT_UPPER, 0, "uppercase-tags: yes", "-u" },
|
||||
{ CmdOptProcDir, "-clean", TC_OPT_CLEAN, 0, "clean: yes", "-c" },
|
||||
{ CmdOptProcDir, "-bare", TC_OPT_BARE, 0, "bare: yes", "-b" },
|
||||
{ CmdOptProcDir, "-gdoc", TC_OPT_GDOC, 0, "gdoc: yes", "-g" },
|
||||
{ CmdOptProcDir, "-numeric", TC_OPT_NUMERIC, 0, "numeric-entities: yes", "-n" },
|
||||
{ CmdOptProcDir, "-errors", TC_OPT_ERRORS, 0, "markup: no", "-e" },
|
||||
{ CmdOptProcDir, "-quiet", TC_OPT_QUIET, 0, "quiet: yes", "-q" },
|
||||
{ CmdOptProcDir, "-omit", TC_OPT_OMIT, 0, "omit-optional-tags: yes" },
|
||||
{ CmdOptProcDir, "-xml", TC_OPT_XML, 0, "input-xml: yes" },
|
||||
{ CmdOptProcDir, "-asxml", TC_OPT_ASXML, 0, "output-xhtml: yes", "-asxhtml" },
|
||||
{ CmdOptProcDir, "-ashtml", TC_OPT_ASHTML, 0, "output-html: yes" },
|
||||
#if SUPPORT_ACCESSIBILITY_CHECKS
|
||||
{ CmdOptProcDir, "-access <%s>", TC_OPT_ACCESS, TC_LABEL_LEVL, "accessibility-check: <%s>" },
|
||||
{ CmdOptProcDir, "-access <%s>", TC_OPT_ACCESS, TC_LABEL_LEVL, "accessibility-check: <%s>" },
|
||||
#endif
|
||||
{ CmdOptCharEnc, "-raw", TC_OPT_RAW, 0, NULL },
|
||||
{ CmdOptCharEnc, "-ascii", TC_OPT_ASCII, 0, NULL },
|
||||
{ CmdOptCharEnc, "-latin0", TC_OPT_LATIN0, 0, NULL },
|
||||
{ CmdOptCharEnc, "-latin1", TC_OPT_LATIN1, 0, NULL },
|
||||
{ CmdOptCharEnc, "-raw", TC_OPT_RAW, 0, NULL },
|
||||
{ CmdOptCharEnc, "-ascii", TC_OPT_ASCII, 0, NULL },
|
||||
{ CmdOptCharEnc, "-latin0", TC_OPT_LATIN0, 0, NULL },
|
||||
{ CmdOptCharEnc, "-latin1", TC_OPT_LATIN1, 0, NULL },
|
||||
#ifndef NO_NATIVE_ISO2022_SUPPORT
|
||||
{ CmdOptCharEnc, "-iso2022", TC_OPT_ISO2022, 0, NULL },
|
||||
{ CmdOptCharEnc, "-iso2022", TC_OPT_ISO2022, 0, NULL },
|
||||
#endif
|
||||
{ CmdOptCharEnc, "-utf8", TC_OPT_UTF8, 0, NULL },
|
||||
{ CmdOptCharEnc, "-mac", TC_OPT_MAC, 0, NULL },
|
||||
{ CmdOptCharEnc, "-win1252", TC_OPT_WIN1252, 0, NULL },
|
||||
{ CmdOptCharEnc, "-ibm858", TC_OPT_IBM858, 0, NULL },
|
||||
{ CmdOptCharEnc, "-utf8", TC_OPT_UTF8, 0, NULL },
|
||||
{ CmdOptCharEnc, "-mac", TC_OPT_MAC, 0, NULL },
|
||||
{ CmdOptCharEnc, "-win1252", TC_OPT_WIN1252, 0, NULL },
|
||||
{ CmdOptCharEnc, "-ibm858", TC_OPT_IBM858, 0, NULL },
|
||||
#if SUPPORT_UTF16_ENCODINGS
|
||||
{ CmdOptCharEnc, "-utf16le", TC_OPT_UTF16LE, 0, NULL },
|
||||
{ CmdOptCharEnc, "-utf16be", TC_OPT_UTF16BE, 0, NULL },
|
||||
{ CmdOptCharEnc, "-utf16", TC_OPT_UTF16, 0, NULL },
|
||||
{ CmdOptCharEnc, "-utf16le", TC_OPT_UTF16LE, 0, NULL },
|
||||
{ CmdOptCharEnc, "-utf16be", TC_OPT_UTF16BE, 0, NULL },
|
||||
{ CmdOptCharEnc, "-utf16", TC_OPT_UTF16, 0, NULL },
|
||||
#endif
|
||||
#if SUPPORT_ASIAN_ENCODINGS /* #431953 - RJ */
|
||||
{ CmdOptCharEnc, "-big5", TC_OPT_BIG5, 0, NULL },
|
||||
{ CmdOptCharEnc, "-shiftjis", TC_OPT_SHIFTJIS, 0, NULL },
|
||||
{ CmdOptCharEnc, "-big5", TC_OPT_BIG5, 0, NULL },
|
||||
{ CmdOptCharEnc, "-shiftjis", TC_OPT_SHIFTJIS, 0, NULL },
|
||||
#endif
|
||||
{ CmdOptMisc, "-version", TC_OPT_VERSION, 0, NULL, "-v" },
|
||||
{ CmdOptMisc, "-help", TC_OPT_HELP, 0, NULL, "-h", "-?" },
|
||||
{ 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, "-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 },
|
||||
{ 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, "-version", TC_OPT_VERSION, 0, NULL, "-v" },
|
||||
{ CmdOptMisc, "-help", TC_OPT_HELP, 0, NULL, "-h", "-?" },
|
||||
{ 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 },
|
||||
{ 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 }
|
||||
};
|
||||
|
||||
|
@ -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