mERGE branch 'next' into issue-456

This commit is contained in:
Geoff McLane 2017-05-27 18:35:01 +02:00
commit 049bc6c288
23 changed files with 2411 additions and 1673 deletions

View file

@ -38,7 +38,7 @@ struct _tidy_option
TidyOptionType type; /* string, int or bool */ TidyOptionType type; /* string, int or bool */
ulong dflt; /* default for TidyInteger and TidyBoolean */ ulong dflt; /* default for TidyInteger and TidyBoolean */
ParseProperty* parser; /* parsing method, read-only if NULL */ ParseProperty* parser; /* parsing method, read-only if NULL */
const ctmbstr* pickList; /* pick list */ PickListItems* pickList; /* pick list */
ctmbstr pdflt; /* default for TidyString */ ctmbstr pdflt; /* default for TidyString */
}; };
~~~ ~~~
@ -78,7 +78,7 @@ Care, each of these enumeration strings have been equated to two uppercase lette
The next item is the `default` value for a boolean, tristate or integer. Note tidy set `no=0` and `yes=1` as its own `Bool` enumeration. The next item is the `default` value for a boolean, tristate or integer. Note tidy set `no=0` and `yes=1` as its own `Bool` enumeration.
There are a number of `parser` for the options. Likewise a number of `pickList`. Find another option similar to your new option and use the same values. There are a number of `parser` for the options. Likewise a number of `pickList`. Find another option similar to your new option and use the same values. The `parser` is the function that parses config file or command line text input, and the `picklist` constitutes the canonical values for the option. Some types of values logically don't have picklists, such as strings or pure integers.
Presently no options have the final `default` string, and it is left out of the table. The compiler will add a NULL. Presently no options have the final `default` string, and it is left out of the table. The compiler will add a NULL.

View file

@ -473,26 +473,20 @@ static tmbstr get_escaped_name( ctmbstr name )
*/ */
/** Utility to determine if an option is an AutoBool. /** Utility to determine if an option has a picklist.
** @param topt The option to check. ** @param topt The option to check.
** @result Returns a Bool indicating whether the option is an Autobool or not. ** @result Returns a Bool indicating whether the option has a picklist or not.
*/ */
static Bool isAutoBool( TidyOption topt ) static Bool hasPickList( TidyOption topt )
{ {
TidyIterator pos; TidyIterator pos;
ctmbstr def;
if ( tidyOptGetType( topt ) != TidyInteger) if ( tidyOptGetType( topt ) != TidyInteger)
return no; return no;
pos = tidyOptGetPickList( topt ); pos = tidyOptGetPickList( topt );
while ( pos )
{ return tidyOptGetNextPick( topt, &pos ) != NULL;
def = tidyOptGetNextPick( topt, &pos );
if (0==strcmp(def,"yes"))
return yes;
}
return no;
} }
/** Returns the configuration category name for the specified configuration /** Returns the configuration category name for the specified configuration
@ -555,16 +549,6 @@ static void GetOption(TidyDoc tdoc, /**< The tidy document. */
/* Handle special cases first. */ /* Handle special cases first. */
switch ( optId ) switch ( optId )
{ {
case TidyDuplicateAttrs:
case TidySortAttributes:
case TidyNewline:
case TidyAccessibilityCheckLevel:
case TidyUseCustomTags:
d->type = "enum";
d->vals = NULL;
d->def = tidyOptGetCurrPick( tdoc, optId );
break;
case TidyDoctype: case TidyDoctype:
d->type = "DocType"; d->type = "DocType";
d->vals = NULL; d->vals = NULL;
@ -576,16 +560,16 @@ static void GetOption(TidyDoc tdoc, /**< The tidy document. */
d->def = sdef; d->def = sdef;
} }
break; break;
case TidyInlineTags: case TidyInlineTags:
case TidyBlockTags: case TidyBlockTags:
case TidyEmptyTags: case TidyEmptyTags:
case TidyPreTags: case TidyPreTags:
d->type = "Tag names"; d->type = "Tag Names";
d->vals = "tagX, tagY, ..."; d->vals = "tagX, tagY, ...";
d->def = NULL; d->def = NULL;
break; break;
case TidyCharEncoding: case TidyCharEncoding:
case TidyInCharEncoding: case TidyInCharEncoding:
case TidyOutCharEncoding: case TidyOutCharEncoding:
@ -602,15 +586,13 @@ static void GetOption(TidyDoc tdoc, /**< The tidy document. */
{ {
case TidyBoolean: case TidyBoolean:
d->type = "Boolean"; d->type = "Boolean";
d->vals = "y/n, yes/no, t/f, true/false, 1/0";
d->def = tidyOptGetCurrPick( tdoc, optId ); d->def = tidyOptGetCurrPick( tdoc, optId );
break; break;
case TidyInteger: case TidyInteger:
if (isAutoBool(topt)) if (hasPickList(topt))
{ {
d->type = "AutoBool"; d->type = "Enum";
d->vals = "auto, y/n, yes/no, t/f, true/false, 1/0";
d->def = tidyOptGetCurrPick( tdoc, optId ); d->def = tidyOptGetCurrPick( tdoc, optId );
} }
else else
@ -621,13 +603,13 @@ static void GetOption(TidyDoc tdoc, /**< The tidy document. */
d->vals = "0 (no wrapping), 1, 2, ..."; d->vals = "0 (no wrapping), 1, 2, ...";
else else
d->vals = "0, 1, 2, ..."; d->vals = "0, 1, 2, ...";
idef = tidyOptGetInt( tdoc, optId ); idef = tidyOptGetInt( tdoc, optId );
sprintf(d->tempdefs, "%u", idef); sprintf(d->tempdefs, "%u", idef);
d->def = d->tempdefs; d->def = d->tempdefs;
} }
break; break;
case TidyString: case TidyString:
d->type = "String"; d->type = "String";
d->vals = NULL; d->vals = NULL;

View file

@ -726,6 +726,36 @@ typedef enum
TidyCR /**< Use Macintosh style: CR */ TidyCR /**< Use Macintosh style: CR */
} TidyLineEnding; } TidyLineEnding;
/** TidyEncodingOptions option values specify the input and/or output encoding.
** @remark This enum's starting value is guaranteed to remain stable.
*/
typedef enum
{
TidyEncRaw = 0,
TidyEncAscii,
TidyEncLatin0,
TidyEncLatin1,
TidyEncUtf8,
#ifndef NO_NATIVE_ISO2022_SUPPORT
TidyEncIso2022,
#endif
TidyEncMac,
TidyEncWin1252,
TidyEncIbm858,
#if SUPPORT_UTF16_ENCODINGS
TidyEncUtf16le,
TidyEncUtf16be,
TidyEncUtf16,
#endif
#if SUPPORT_ASIAN_ENCODINGS
TidyEncBig5,
TidyEncShiftjis
#endif
} TidyEncodingOptions;
/** Mode controlling treatment of doctype /** Mode controlling treatment of doctype
** @remark This enum's starting value is guaranteed to remain stable. ** @remark This enum's starting value is guaranteed to remain stable.
@ -758,6 +788,16 @@ typedef enum
TidySortAttrAlpha /**< Sort attributes alphabetically */ TidySortAttrAlpha /**< Sort attributes alphabetically */
} TidyAttrSortStrategy; } TidyAttrSortStrategy;
/** Mode controlling capitalization of things, such as attributes.
** @remark This enum's starting value is guaranteed to remain stable.
*/
typedef enum
{
TidyUppercaseNo = 0, /**< Don't uppercase. */
TidyUppercaseYes, /**< Do uppercase. */
TidyUppercasePreserve /**< Preserve case. */
} TidyUppercase;
/** @} /** @}
** @name Document Tree ** @name Document Tree

View file

@ -5,7 +5,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n" "Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: HTML Tidy poconvert.rb\n" "X-Generator: HTML Tidy poconvert.rb\n"
"Project-Id-Version: \n" "Project-Id-Version: \n"
"PO-Revision-Date: 2017-03-22 15:54:52\n" "PO-Revision-Date: 2017-05-13 21:04:45\n"
"Last-Translator: jderry\n" "Last-Translator: jderry\n"
"Language-Team: \n" "Language-Team: \n"
@ -299,32 +299,6 @@ msgctxt "TidyDropEmptyParas"
msgid "This option specifies if Tidy should discard empty paragraphs. " msgid "This option specifies if Tidy should discard empty paragraphs. "
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyDropFontTags"
msgid ""
"Deprecated; <em>do not use</em>. This option is destructive to "
"<code>&lt;font&gt;</code> tags, and it will be removed from future "
"versions of Tidy. Use the <code>clean</code> option instead. "
"<br/>"
"If you do set this option despite the warning it will perform "
"as <code>clean</code> except styles will be inline instead of put into "
"a CSS class. <code>&lt;font&gt;</code> tags will be dropped completely "
"and their styles will not be preserved. "
"<br/>"
"If both <code>clean</code> and this option are enabled, "
"<code>&lt;font&gt;</code> tags will still be dropped completely, and "
"other styles will be preserved in a CSS class instead of inline. "
"<br/>"
"See <code>clean</code> for more information. "
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -557,18 +531,6 @@ msgctxt "TidyHideComments"
msgid "This option specifies if Tidy should print out comments. " msgid "This option specifies if Tidy should print out comments. "
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyHideEndTags"
msgid "This option is an alias for <code>omit-optional-tags</code>. "
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -1301,10 +1263,10 @@ msgstr ""
msgctxt "TidyStrictTagsAttr" msgctxt "TidyStrictTagsAttr"
msgid "" msgid ""
"This options ensures that tags and attributes are applicable for the " "This options ensures that tags and attributes are applicable for the "
"version of HTML that Tidy outputs. When set to <var>yes</var> (the " "version of HTML that Tidy outputs. When set to <var>yes</var> and the "
"default) and the output document type is a strict doctype, then Tidy " "output document type is a strict doctype, then Tidy will report "
"will report errors. If the output document type is a loose or " "errors. If the output document type is a loose or transitional "
"transitional doctype, then Tidy will report warnings. " "doctype, then Tidy will report warnings. "
"<br/>" "<br/>"
"Additionally if <code>drop-proprietary-attributes</code> is enabled, " "Additionally if <code>drop-proprietary-attributes</code> is enabled, "
"then not applicable attributes will be dropped, too. " "then not applicable attributes will be dropped, too. "
@ -1406,6 +1368,18 @@ msgid ""
"characters." "characters."
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyWarnPropAttrs"
msgid "This option specifies if Tidy should warn on proprietary attributes."
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -1745,6 +1719,11 @@ msgctxt "FILE_CANT_OPEN"
msgid "Can't open \"%s\"\n" msgid "Can't open \"%s\"\n"
msgstr "" msgstr ""
#, c-format
msgctxt "FILE_NOT_FILE"
msgid "\"%s\" is not a file!\n"
msgstr ""
#, c-format #, c-format
msgctxt "LINE_COLUMN_STRING" msgctxt "LINE_COLUMN_STRING"
msgid "line %d column %d - " msgid "line %d column %d - "
@ -1880,16 +1859,6 @@ msgid ""
" TD cells that set the axis attribute are also treated as header cells.\n" " TD cells that set the axis attribute are also treated as header cells.\n"
msgstr "" msgstr ""
#. This console output should be limited to 78 characters per line.
msgctxt "TEXT_WINDOWS_CHARS"
msgid ""
"Characters codes for the Microsoft Windows fonts in the range\n"
"128 - 159 may not be recognized on other platforms. You are\n"
"instead recommended to use named entities, e.g. &trade; rather\n"
"than Windows character code 153 (0x2122 in Unicode). Note that\n"
"as of February 1998 few browsers support the new entities.\n"
msgstr ""
#. This console output should be limited to 78 characters per line. #. This console output should be limited to 78 characters per line.
#. - %s represents a string-encoding name which may be localized in your language. #. - %s represents a string-encoding name which may be localized in your language.
#, c-format #, c-format
@ -2145,6 +2114,11 @@ msgctxt "ID_NAME_MISMATCH"
msgid "%s id and name attribute value mismatch" msgid "%s id and name attribute value mismatch"
msgstr "" msgstr ""
#, c-format
msgctxt "ILLEGAL_URI_CODEPOINT"
msgid "%s illegal characters found in URI"
msgstr ""
#, c-format #, c-format
msgctxt "ILLEGAL_URI_REFERENCE" msgctxt "ILLEGAL_URI_REFERENCE"
msgid "%s improperly escaped URI reference" msgid "%s improperly escaped URI reference"

View file

@ -5,7 +5,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n" "Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: HTML Tidy poconvert.rb\n" "X-Generator: HTML Tidy poconvert.rb\n"
"Project-Id-Version: \n" "Project-Id-Version: \n"
"PO-Revision-Date: 2017-03-22 15:54:52\n" "PO-Revision-Date: 2017-05-13 21:04:45\n"
"Last-Translator: jderry\n" "Last-Translator: jderry\n"
"Language-Team: \n" "Language-Team: \n"
@ -299,32 +299,6 @@ msgctxt "TidyDropEmptyParas"
msgid "This option specifies if Tidy should discard empty paragraphs. " msgid "This option specifies if Tidy should discard empty paragraphs. "
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyDropFontTags"
msgid ""
"Deprecated; <em>do not use</em>. This option is destructive to "
"<code>&lt;font&gt;</code> tags, and it will be removed from future "
"versions of Tidy. Use the <code>clean</code> option instead. "
"<br/>"
"If you do set this option despite the warning it will perform "
"as <code>clean</code> except styles will be inline instead of put into "
"a CSS class. <code>&lt;font&gt;</code> tags will be dropped completely "
"and their styles will not be preserved. "
"<br/>"
"If both <code>clean</code> and this option are enabled, "
"<code>&lt;font&gt;</code> tags will still be dropped completely, and "
"other styles will be preserved in a CSS class instead of inline. "
"<br/>"
"See <code>clean</code> for more information. "
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -557,18 +531,6 @@ msgctxt "TidyHideComments"
msgid "This option specifies if Tidy should print out comments. " msgid "This option specifies if Tidy should print out comments. "
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyHideEndTags"
msgid "This option is an alias for <code>omit-optional-tags</code>. "
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -1282,10 +1244,10 @@ msgstr ""
msgctxt "TidyStrictTagsAttr" msgctxt "TidyStrictTagsAttr"
msgid "" msgid ""
"This options ensures that tags and attributes are applicable for the " "This options ensures that tags and attributes are applicable for the "
"version of HTML that Tidy outputs. When set to <var>yes</var> (the " "version of HTML that Tidy outputs. When set to <var>yes</var> and the "
"default) and the output document type is a strict doctype, then Tidy " "output document type is a strict doctype, then Tidy will report "
"will report errors. If the output document type is a loose or " "errors. If the output document type is a loose or transitional "
"transitional doctype, then Tidy will report warnings. " "doctype, then Tidy will report warnings. "
"<br/>" "<br/>"
"Additionally if <code>drop-proprietary-attributes</code> is enabled, " "Additionally if <code>drop-proprietary-attributes</code> is enabled, "
"then not applicable attributes will be dropped, too. " "then not applicable attributes will be dropped, too. "
@ -1387,6 +1349,18 @@ msgid ""
"characters." "characters."
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyWarnPropAttrs"
msgid "This option specifies if Tidy should warn on proprietary attributes."
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -1726,6 +1700,11 @@ msgctxt "FILE_CANT_OPEN"
msgid "Can't open \"%s\"\n" msgid "Can't open \"%s\"\n"
msgstr "" msgstr ""
#, c-format
msgctxt "FILE_NOT_FILE"
msgid "\"%s\" is not a file!\n"
msgstr ""
#, c-format #, c-format
msgctxt "LINE_COLUMN_STRING" msgctxt "LINE_COLUMN_STRING"
msgid "line %d column %d - " msgid "line %d column %d - "
@ -1861,16 +1840,6 @@ msgid ""
" TD cells that set the axis attribute are also treated as header cells.\n" " TD cells that set the axis attribute are also treated as header cells.\n"
msgstr "" msgstr ""
#. This console output should be limited to 78 characters per line.
msgctxt "TEXT_WINDOWS_CHARS"
msgid ""
"Characters codes for the Microsoft Windows fonts in the range\n"
"128 - 159 may not be recognized on other platforms. You are\n"
"instead recommended to use named entities, e.g. &trade; rather\n"
"than Windows character code 153 (0x2122 in Unicode). Note that\n"
"as of February 1998 few browsers support the new entities.\n"
msgstr ""
#. This console output should be limited to 78 characters per line. #. This console output should be limited to 78 characters per line.
#. - %s represents a string-encoding name which may be localized in your language. #. - %s represents a string-encoding name which may be localized in your language.
#, c-format #, c-format
@ -2122,6 +2091,11 @@ msgctxt "ID_NAME_MISMATCH"
msgid "%s id and name attribute value mismatch" msgid "%s id and name attribute value mismatch"
msgstr "" msgstr ""
#, c-format
msgctxt "ILLEGAL_URI_CODEPOINT"
msgid "%s illegal characters found in URI"
msgstr ""
#, c-format #, c-format
msgctxt "ILLEGAL_URI_REFERENCE" msgctxt "ILLEGAL_URI_REFERENCE"
msgid "%s improperly escaped URI reference" msgid "%s improperly escaped URI reference"

View file

@ -5,7 +5,7 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n" "Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: HTML Tidy poconvert.rb\n" "X-Generator: HTML Tidy poconvert.rb\n"
"Project-Id-Version: \n" "Project-Id-Version: \n"
"PO-Revision-Date: 2017-03-22 15:54:52\n" "PO-Revision-Date: 2017-05-13 21:04:45\n"
"Last-Translator: jderry\n" "Last-Translator: jderry\n"
"Language-Team: \n" "Language-Team: \n"
@ -299,32 +299,6 @@ msgctxt "TidyDropEmptyParas"
msgid "This option specifies if Tidy should discard empty paragraphs. " msgid "This option specifies if Tidy should discard empty paragraphs. "
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyDropFontTags"
msgid ""
"Deprecated; <em>do not use</em>. This option is destructive to "
"<code>&lt;font&gt;</code> tags, and it will be removed from future "
"versions of Tidy. Use the <code>clean</code> option instead. "
"<br/>"
"If you do set this option despite the warning it will perform "
"as <code>clean</code> except styles will be inline instead of put into "
"a CSS class. <code>&lt;font&gt;</code> tags will be dropped completely "
"and their styles will not be preserved. "
"<br/>"
"If both <code>clean</code> and this option are enabled, "
"<code>&lt;font&gt;</code> tags will still be dropped completely, and "
"other styles will be preserved in a CSS class instead of inline. "
"<br/>"
"See <code>clean</code> for more information. "
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -557,18 +531,6 @@ msgctxt "TidyHideComments"
msgid "This option specifies if Tidy should print out comments. " msgid "This option specifies if Tidy should print out comments. "
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyHideEndTags"
msgid "This option is an alias for <code>omit-optional-tags</code>. "
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -1277,10 +1239,10 @@ msgstr ""
msgctxt "TidyStrictTagsAttr" msgctxt "TidyStrictTagsAttr"
msgid "" msgid ""
"This options ensures that tags and attributes are applicable for the " "This options ensures that tags and attributes are applicable for the "
"version of HTML that Tidy outputs. When set to <var>yes</var> (the " "version of HTML that Tidy outputs. When set to <var>yes</var> and the "
"default) and the output document type is a strict doctype, then Tidy " "output document type is a strict doctype, then Tidy will report "
"will report errors. If the output document type is a loose or " "errors. If the output document type is a loose or transitional "
"transitional doctype, then Tidy will report warnings. " "doctype, then Tidy will report warnings. "
"<br/>" "<br/>"
"Additionally if <code>drop-proprietary-attributes</code> is enabled, " "Additionally if <code>drop-proprietary-attributes</code> is enabled, "
"then not applicable attributes will be dropped, too. " "then not applicable attributes will be dropped, too. "
@ -1382,6 +1344,18 @@ msgid ""
"characters." "characters."
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyWarnPropAttrs"
msgid "This option specifies if Tidy should warn on proprietary attributes."
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -1721,6 +1695,11 @@ msgctxt "FILE_CANT_OPEN"
msgid "Can't open \"%s\"\n" msgid "Can't open \"%s\"\n"
msgstr "" msgstr ""
#, c-format
msgctxt "FILE_NOT_FILE"
msgid "\"%s\" is not a file!\n"
msgstr ""
#, c-format #, c-format
msgctxt "LINE_COLUMN_STRING" msgctxt "LINE_COLUMN_STRING"
msgid "line %d column %d - " msgid "line %d column %d - "
@ -1856,16 +1835,6 @@ msgid ""
" TD cells that set the axis attribute are also treated as header cells.\n" " TD cells that set the axis attribute are also treated as header cells.\n"
msgstr "" msgstr ""
#. This console output should be limited to 78 characters per line.
msgctxt "TEXT_WINDOWS_CHARS"
msgid ""
"Characters codes for the Microsoft Windows fonts in the range\n"
"128 - 159 may not be recognized on other platforms. You are\n"
"instead recommended to use named entities, e.g. &trade; rather\n"
"than Windows character code 153 (0x2122 in Unicode). Note that\n"
"as of February 1998 few browsers support the new entities.\n"
msgstr ""
#. This console output should be limited to 78 characters per line. #. This console output should be limited to 78 characters per line.
#. - %s represents a string-encoding name which may be localized in your language. #. - %s represents a string-encoding name which may be localized in your language.
#, c-format #, c-format
@ -2117,6 +2086,11 @@ msgctxt "ID_NAME_MISMATCH"
msgid "%s id and name attribute value mismatch" msgid "%s id and name attribute value mismatch"
msgstr "" msgstr ""
#, c-format
msgctxt "ILLEGAL_URI_CODEPOINT"
msgid "%s illegal characters found in URI"
msgstr ""
#, c-format #, c-format
msgctxt "ILLEGAL_URI_REFERENCE" msgctxt "ILLEGAL_URI_REFERENCE"
msgid "%s improperly escaped URI reference" msgid "%s improperly escaped URI reference"

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,7 @@ msgstr ""
"Plural-Forms: nplurals=1; plural=0;\n" "Plural-Forms: nplurals=1; plural=0;\n"
"X-Generator: HTML Tidy poconvert.rb\n" "X-Generator: HTML Tidy poconvert.rb\n"
"Project-Id-Version: \n" "Project-Id-Version: \n"
"PO-Revision-Date: 2017-03-22 15:54:52\n" "PO-Revision-Date: 2017-05-13 21:04:45\n"
"Last-Translator: jderry\n" "Last-Translator: jderry\n"
"Language-Team: \n" "Language-Team: \n"
@ -299,32 +299,6 @@ msgctxt "TidyDropEmptyParas"
msgid "This option specifies if Tidy should discard empty paragraphs. " msgid "This option specifies if Tidy should discard empty paragraphs. "
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyDropFontTags"
msgid ""
"Deprecated; <em>do not use</em>. This option is destructive to "
"<code>&lt;font&gt;</code> tags, and it will be removed from future "
"versions of Tidy. Use the <code>clean</code> option instead. "
"<br/>"
"If you do set this option despite the warning it will perform "
"as <code>clean</code> except styles will be inline instead of put into "
"a CSS class. <code>&lt;font&gt;</code> tags will be dropped completely "
"and their styles will not be preserved. "
"<br/>"
"If both <code>clean</code> and this option are enabled, "
"<code>&lt;font&gt;</code> tags will still be dropped completely, and "
"other styles will be preserved in a CSS class instead of inline. "
"<br/>"
"See <code>clean</code> for more information. "
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -557,18 +531,6 @@ msgctxt "TidyHideComments"
msgid "This option specifies if Tidy should print out comments. " msgid "This option specifies if Tidy should print out comments. "
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyHideEndTags"
msgid "This option is an alias for <code>omit-optional-tags</code>. "
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -1277,10 +1239,10 @@ msgstr ""
msgctxt "TidyStrictTagsAttr" msgctxt "TidyStrictTagsAttr"
msgid "" msgid ""
"This options ensures that tags and attributes are applicable for the " "This options ensures that tags and attributes are applicable for the "
"version of HTML that Tidy outputs. When set to <var>yes</var> (the " "version of HTML that Tidy outputs. When set to <var>yes</var> and the "
"default) and the output document type is a strict doctype, then Tidy " "output document type is a strict doctype, then Tidy will report "
"will report errors. If the output document type is a loose or " "errors. If the output document type is a loose or transitional "
"transitional doctype, then Tidy will report warnings. " "doctype, then Tidy will report warnings. "
"<br/>" "<br/>"
"Additionally if <code>drop-proprietary-attributes</code> is enabled, " "Additionally if <code>drop-proprietary-attributes</code> is enabled, "
"then not applicable attributes will be dropped, too. " "then not applicable attributes will be dropped, too. "
@ -1382,6 +1344,18 @@ msgid ""
"characters." "characters."
msgstr "" msgstr ""
#. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>.
#. - Entities, tags, attributes, etc., should be enclosed in <code></code>.
#. - Option values should be enclosed in <var></var>.
#. - It's very important that <br/> be self-closing!
#. - The strings "Tidy" and "HTML Tidy" are the program name and must not
#. be translated.
msgctxt "TidyWarnPropAttrs"
msgid "This option specifies if Tidy should warn on proprietary attributes."
msgstr ""
#. Important notes for translators: #. Important notes for translators:
#. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and #. - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and
#. <br/>. #. <br/>.
@ -1721,6 +1695,11 @@ msgctxt "FILE_CANT_OPEN"
msgid "Can't open \"%s\"\n" msgid "Can't open \"%s\"\n"
msgstr "无法打开”%s”\n" msgstr "无法打开”%s”\n"
#, c-format
msgctxt "FILE_NOT_FILE"
msgid "\"%s\" is not a file!\n"
msgstr ""
#, c-format #, c-format
msgctxt "LINE_COLUMN_STRING" msgctxt "LINE_COLUMN_STRING"
msgid "line %d column %d - " msgid "line %d column %d - "
@ -1854,16 +1833,6 @@ msgid ""
" TD cells that set the axis attribute are also treated as header cells.\n" " TD cells that set the axis attribute are also treated as header cells.\n"
msgstr "" msgstr ""
#. This console output should be limited to 78 characters per line.
msgctxt "TEXT_WINDOWS_CHARS"
msgid ""
"Characters codes for the Microsoft Windows fonts in the range\n"
"128 - 159 may not be recognized on other platforms. You are\n"
"instead recommended to use named entities, e.g. &trade; rather\n"
"than Windows character code 153 (0x2122 in Unicode). Note that\n"
"as of February 1998 few browsers support the new entities.\n"
msgstr ""
#. This console output should be limited to 78 characters per line. #. This console output should be limited to 78 characters per line.
#. - %s represents a string-encoding name which may be localized in your language. #. - %s represents a string-encoding name which may be localized in your language.
#, c-format #, c-format
@ -2111,6 +2080,11 @@ msgctxt "ID_NAME_MISMATCH"
msgid "%s id and name attribute value mismatch" msgid "%s id and name attribute value mismatch"
msgstr "" msgstr ""
#, c-format
msgctxt "ILLEGAL_URI_CODEPOINT"
msgid "%s illegal characters found in URI"
msgstr ""
#, c-format #, c-format
msgctxt "ILLEGAL_URI_REFERENCE" msgctxt "ILLEGAL_URI_REFERENCE"
msgid "%s improperly escaped URI reference" msgid "%s improperly escaped URI reference"

View file

@ -824,15 +824,15 @@ static const Attribute* attrsLookup(TidyDocImpl* doc,
#if ATTRIBUTE_HASH_LOOKUP #if ATTRIBUTE_HASH_LOOKUP
for (p = attribs->hashtab[attrsHash(atnam)]; p && p->attr; p = p->next) for (p = attribs->hashtab[attrsHash(atnam)]; p && p->attr; p = p->next)
if (TY_(tmbstrcmp)(atnam, p->attr->name) == 0) if (TY_(tmbstrcasecmp)(atnam, p->attr->name) == 0)
return p->attr; return p->attr;
for (np = attribute_defs; np && np->name; ++np) for (np = attribute_defs; np && np->name; ++np)
if (TY_(tmbstrcmp)(atnam, np->name) == 0) if (TY_(tmbstrcasecmp)(atnam, np->name) == 0)
return attrsInstall(doc, attribs, np); return attrsInstall(doc, attribs, np);
#else #else
for (np = attribute_defs; np && np->name; ++np) for (np = attribute_defs; np && np->name; ++np)
if (TY_(tmbstrcmp)(atnam, np->name) == 0) if (TY_(tmbstrcasecmp)(atnam, np->name) == 0)
return np; return np;
#endif #endif
@ -1617,7 +1617,7 @@ void TY_(CheckUrl)( TidyDocImpl* doc, Node *node, AttVal *attval)
{ {
if ( cfgBool(doc, TidyFixUri) ) if ( cfgBool(doc, TidyFixUri) )
TY_(ReportAttrError)( doc, node, attval, ESCAPED_ILLEGAL_URI); TY_(ReportAttrError)( doc, node, attval, ESCAPED_ILLEGAL_URI);
else else if ( !(TY_(HTMLVersion)(doc) & VERS_HTML5) )
TY_(ReportAttrError)( doc, node, attval, ILLEGAL_URI_REFERENCE); TY_(ReportAttrError)( doc, node, attval, ILLEGAL_URI_REFERENCE);
doc->badChars |= BC_INVALID_URI; doc->badChars |= BC_INVALID_URI;

View file

@ -1,22 +1,12 @@
/* /* config.c
config.c -- read config file and manage config properties * Read configuration files and manage configuration properties.
*
(c) 1998-2008 (W3C) MIT, ERCIM, Keio University * Copyright (c) 1998-2017 World Wide Web Consortium (Massachusetts
See tidy.h for the copyright notice. * Institute of Technology, European Research Consortium for Informatics
* and Mathematics, Keio University) and HTACG.
config files associate a property name with a value. *
* See tidy.h for the copyright notice.
// comments can start at the beginning of a line */
# comments can start at the beginning of a line
name: short values fit onto one line
name: a really long value that
continues on the next line
property names are case insensitive and should be less than
60 characters in length and must start at the begining of
the line, as whitespace at the start of a line signifies a
line continuation.
*/
#include "config.h" #include "config.h"
#include "tidy-int.h" #include "tidy-int.h"
@ -29,8 +19,9 @@
#else #else
#ifdef DMALLOC #ifdef DMALLOC
/* /*
macro for valloc() in dmalloc.h may conflict with declaration for valloc() in unistd.h - macro for valloc() in dmalloc.h may conflict with declaration for valloc()
we don't need (debugging for) valloc() here. dmalloc.h should come last but it doesn't. in unistd.h - we don't need (debugging for) valloc() here. dmalloc.h should
come last but it doesn't.
*/ */
#ifdef valloc #ifdef valloc
#undef valloc #undef valloc
@ -56,103 +47,106 @@ void TY_(FreeConfig)( TidyDocImpl* doc )
} }
/* Arrange so index can be cast to enum /*
Arrange so index can be cast to enum. Note that the value field in the
following structures is not currently used in code; they're present for
documentation purposes currently. The arrays must be populated in enum order.
*/ */
static const ctmbstr boolPicks[] = static PickListItems boolPicks = {
{ { "no", TidyNoState, { "0", "n", "f", "no", "false", NULL } },
"no", { "yes", TidyYesState, { "1", "y", "t", "yes", "true", NULL } },
"yes", { NULL }
NULL
}; };
static const ctmbstr autoBoolPicks[] = static PickListItems autoBoolPicks = {
{ { "no", TidyNoState, { "0", "n", "f", "no", "false", NULL } },
"no", { "yes", TidyYesState, { "1", "y", "t", "yes", "true", NULL } },
"yes", { "auto", TidyYesState, { "auto", NULL } },
"auto", { NULL }
NULL
}; };
static const ctmbstr repeatAttrPicks[] = static PickListItems repeatAttrPicks = {
{ { "keep-first", TidyNoState, { "keep-first", NULL } },
"keep-first", { "keep-last", TidyYesState, { "keep-last", NULL } },
"keep-last", { NULL }
NULL
}; };
static const ctmbstr accessPicks[] = static PickListItems accessPicks = {
{ { "0 (Tidy Classic)", 0, { "0", "0 (Tidy Classic)", NULL } },
"0 (Tidy Classic)", { "1 (Priority 1 Checks)", 1, { "1", "1 (Priority 1 Checks)", NULL } },
"1 (Priority 1 Checks)", { "2 (Priority 2 Checks)", 2, { "2", "2 (Priority 2 Checks)", NULL } },
"2 (Priority 2 Checks)", { "3 (Priority 3 Checks)", 3, { "3", "3 (Priority 3 Checks)", NULL } },
"3 (Priority 3 Checks)", { NULL }
NULL
}; };
static const ctmbstr charEncPicks[] = static PickListItems charEncPicks = {
{ { "raw", TidyEncRaw, { "raw", NULL } },
"raw", { "ascii", TidyEncAscii, { "ascii", NULL } },
"ascii", { "latin0", TidyEncLatin0, { "latin0", NULL } },
"latin0", { "latin1", TidyEncLatin1, { "latin1", NULL } },
"latin1", { "utf8", TidyEncUtf8, { "utf8", NULL } },
"utf8",
#ifndef NO_NATIVE_ISO2022_SUPPORT #ifndef NO_NATIVE_ISO2022_SUPPORT
"iso2022", { "iso2022", TidyEncIso2022, { "iso2022", NULL } },
#endif #endif
"mac", { "mac", TidyEncMac, { "mac", NULL } },
"win1252", { "win1252", TidyEncWin1252, { "win1252", NULL } },
"ibm858", { "ibm858", TidyEncIbm858, { "ibm858", NULL } },
#if SUPPORT_UTF16_ENCODINGS #if SUPPORT_UTF16_ENCODINGS
"utf16le", { "utf16le", TidyEncUtf16le, { "utf16le", NULL } },
"utf16be", { "utf16be", TidyEncUtf16be, { "utf16be", NULL } },
"utf16", { "utf16", TidyEncUtf16, { "utf16", NULL } },
#endif #endif
#if SUPPORT_ASIAN_ENCODINGS #if SUPPORT_ASIAN_ENCODINGS
"big5", { "big5", TidyEncBig5, { "big5", NULL } },
"shiftjis", { "shiftjis", TidyEncShiftjis, { "shiftjis", NULL } },
#endif #endif
NULL { NULL }
}; };
static const ctmbstr newlinePicks[] = static PickListItems newlinePicks = {
{ { "LF", TidyLF, { "lf", NULL } },
"LF", { "CRLF", TidyCRLF, { "crlf", NULL } },
"CRLF", { "CR", TidyCR, { "cr", NULL } },
"CR", { NULL }
NULL
}; };
static const ctmbstr doctypePicks[] = static PickListItems doctypePicks = {
{ { "html5", TidyDoctypeHtml5, { "html5", NULL } },
"html5", { "omit", TidyDoctypeOmit, { "omit", NULL } },
"omit", { "auto", TidyDoctypeAuto, { "auto", NULL } },
"auto", { "strict", TidyDoctypeStrict, { "strict", NULL } },
"strict", { "transitional", TidyDoctypeLoose, { "loose", "transitional", NULL } },
"transitional", { "user", TidyDoctypeUser, { "user", NULL } },
"user", { NULL }
NULL
}; };
static const ctmbstr sorterPicks[] = static PickListItems sorterPicks = {
{ { "none", TidySortAttrNone, { "none", NULL } },
"none", { "alpha", TidySortAttrAlpha, { "alpha", NULL } },
"alpha", { NULL }
NULL
}; };
static const ctmbstr customTagsPicks[] = static PickListItems customTagsPicks = {
{ {"no", TidyCustomNo, { "no", "n", NULL } },
"no", {"blocklevel", TidyCustomBlocklevel, { "blocklevel", NULL } },
"blocklevel", {"empty", TidyCustomEmpty, { "empty", NULL } },
"empty", {"inline", TidyCustomInline, { "inline", "y", "yes", NULL } },
"inline", {"pre", TidyCustomPre, { "pre", NULL } },
"pre", { NULL }
NULL
}; };
static PickListItems attributeCasePicks = {
{ "no", TidyUppercaseNo, { "0", "n", "f", "no", "false", NULL } },
{ "yes", TidyUppercaseYes, { "1", "y", "t", "yes", "true", NULL } },
{ "preserve", TidyUppercasePreserve, { "preserve", NULL } },
{ NULL }
};
#define MU TidyMarkup #define MU TidyMarkup
#define DG TidyDiagnostics #define DG TidyDiagnostics
#define PP TidyPrettyPrint #define PP TidyPrettyPrint
@ -171,7 +165,7 @@ static const ctmbstr customTagsPicks[] =
/* If Accessibility checks not supported, make config setting read-only */ /* If Accessibility checks not supported, make config setting read-only */
#if SUPPORT_ACCESSIBILITY_CHECKS #if SUPPORT_ACCESSIBILITY_CHECKS
#define ParseAcc ParseInt #define ParseAcc ParsePickList
#else #else
#define ParseAcc NULL #define ParseAcc NULL
#endif #endif
@ -181,13 +175,6 @@ static void AdjustConfig( TidyDocImpl* doc );
/* parser for integer values */ /* parser for integer values */
static ParseProperty ParseInt; static ParseProperty ParseInt;
/* parser for 't'/'f', 'true'/'false', 'y'/'n', 'yes'/'no' or '1'/'0' */
static ParseProperty ParseBool;
/* parser for 't'/'f', 'true'/'false', 'y'/'n', 'yes'/'no', '1'/'0'
or 'auto' */
static ParseProperty ParseAutoBool;
/* a string excluding whitespace */ /* a string excluding whitespace */
static ParseProperty ParseName; static ParseProperty ParseName;
@ -200,108 +187,97 @@ static ParseProperty ParseString;
/* a space or comma separated list of tag names */ /* a space or comma separated list of tag names */
static ParseProperty ParseTagNames; static ParseProperty ParseTagNames;
/* alpha */ /* RAW, ASCII, LATIN0, LATIN1, UTF8, ISO2022, MACROMAN,
static ParseProperty ParseSorter;
/* RAW, ASCII, LATIN0, LATIN1, UTF8, ISO2022, MACROMAN,
WIN1252, IBM858, UTF16LE, UTF16BE, UTF16, BIG5, SHIFTJIS WIN1252, IBM858, UTF16LE, UTF16BE, UTF16, BIG5, SHIFTJIS
*/ */
static ParseProperty ParseCharEnc; static ParseProperty ParseCharEnc;
static ParseProperty ParseNewline;
/* html5 | omit | auto | strict | loose | <fpi> */ /* html5 | omit | auto | strict | loose | <fpi> */
static ParseProperty ParseDocType; static ParseProperty ParseDocType;
/* keep-first or keep-last? */ /* 20150515 - support using tabs instead of spaces - Issue #108
static ParseProperty ParseRepeatAttr; */
/*\
* 20150515 - support using tabs instead of spaces - Issue #108
* (a) parser for 't'/'f', 'true'/'false', 'y'/'n', 'yes'/'no' or '1'/'0'
* (b) sets the TidyIndentSpaces to 1 if 'yes'
* (c) sets the indent_char to '\t' or ' '
\*/
static ParseProperty ParseTabs; static ParseProperty ParseTabs;
/* Parse the value of TidyUseCustomTags */ /* General parser for options having picklists */
static ParseProperty ParseUseCustomTags; static ParseProperty ParsePickList;
/* Ensure struct order is same order as tidyenum.h:TidyOptionId! */ /* Ensure struct order is same order as tidyenum.h:TidyOptionId! */
static const TidyOptionImpl option_defs[] = static const TidyOptionImpl option_defs[] =
{ {
{ TidyUnknownOption, MS, "unknown!", IN, 0, NULL, NULL }, { TidyUnknownOption, MS, "unknown!", IN, 0, NULL, NULL },
{ TidyAccessibilityCheckLevel, DG, "accessibility-check", IN, 0, ParseAcc, accessPicks }, { TidyAccessibilityCheckLevel, DG, "accessibility-check", IN, 0, ParseAcc, &accessPicks },
{ TidyAltText, MU, "alt-text", ST, 0, ParseString, NULL }, { TidyAltText, MU, "alt-text", ST, 0, ParseString, NULL },
{ TidyAnchorAsName, MU, "anchor-as-name", BL, yes, ParseBool, boolPicks }, { TidyAnchorAsName, MU, "anchor-as-name", BL, yes, ParsePickList, &boolPicks },
{ TidyAsciiChars, CE, "ascii-chars", BL, no, ParseBool, boolPicks }, { TidyAsciiChars, CE, "ascii-chars", BL, no, ParsePickList, &boolPicks },
{ TidyBlockTags, MU, "new-blocklevel-tags", ST, 0, ParseTagNames, NULL }, { TidyBlockTags, MU, "new-blocklevel-tags", ST, 0, ParseTagNames, NULL },
{ TidyBodyOnly, MU, "show-body-only", IN, no, ParseAutoBool, autoBoolPicks }, { TidyBodyOnly, MU, "show-body-only", IN, no, ParsePickList, &autoBoolPicks },
{ TidyBreakBeforeBR, PP, "break-before-br", BL, no, ParseBool, boolPicks }, { TidyBreakBeforeBR, PP, "break-before-br", BL, no, ParsePickList, &boolPicks },
{ TidyCharEncoding, CE, "char-encoding", IN, UTF8, ParseCharEnc, charEncPicks }, { TidyCharEncoding, CE, "char-encoding", IN, UTF8, ParseCharEnc, &charEncPicks },
{ TidyCoerceEndTags, MU, "coerce-endtags", BL, yes, ParseBool, boolPicks }, { TidyCoerceEndTags, MU, "coerce-endtags", BL, yes, ParsePickList, &boolPicks },
{ TidyCSSPrefix, MU, "css-prefix", ST, 0, ParseCSS1Selector, NULL }, { TidyCSSPrefix, MU, "css-prefix", ST, 0, ParseCSS1Selector, NULL },
{ TidyCustomTags, IR, "new-custom-tags", ST, 0, ParseTagNames, NULL }, /* 20170309 - Issue #119 */ { TidyCustomTags, IR, "new-custom-tags", ST, 0, ParseTagNames, NULL }, /* 20170309 - Issue #119 */
{ TidyDecorateInferredUL, MU, "decorate-inferred-ul", BL, no, ParseBool, boolPicks }, { TidyDecorateInferredUL, MU, "decorate-inferred-ul", BL, no, ParsePickList, &boolPicks },
{ TidyDoctype, MU, "doctype", ST, 0, ParseDocType, doctypePicks }, { TidyDoctype, MU, "doctype", ST, 0, ParseDocType, &doctypePicks },
#ifndef DOXYGEN_SHOULD_SKIP_THIS #ifndef DOXYGEN_SHOULD_SKIP_THIS
{ TidyDoctypeMode, IR, "doctype-mode", IN, TidyDoctypeAuto, NULL, doctypePicks }, { TidyDoctypeMode, IR, "doctype-mode", IN, TidyDoctypeAuto, NULL, &doctypePicks },
#endif #endif
{ TidyDropEmptyElems, MU, "drop-empty-elements", BL, yes, ParseBool, boolPicks }, { TidyDropEmptyElems, MU, "drop-empty-elements", BL, yes, ParsePickList, &boolPicks },
{ TidyDropEmptyParas, MU, "drop-empty-paras", BL, yes, ParseBool, boolPicks }, { TidyDropEmptyParas, MU, "drop-empty-paras", BL, yes, ParsePickList, &boolPicks },
{ TidyDropPropAttrs, MU, "drop-proprietary-attributes", BL, no, ParseBool, boolPicks }, { TidyDropPropAttrs, MU, "drop-proprietary-attributes", BL, no, ParsePickList, &boolPicks },
{ TidyDuplicateAttrs, MU, "repeated-attributes", IN, TidyKeepLast, ParseRepeatAttr, repeatAttrPicks }, { TidyDuplicateAttrs, MU, "repeated-attributes", IN, TidyKeepLast, ParsePickList, &repeatAttrPicks },
{ TidyEmacs, MS, "gnu-emacs", BL, no, ParseBool, boolPicks }, { TidyEmacs, MS, "gnu-emacs", BL, no, ParsePickList, &boolPicks },
#ifndef DOXYGEN_SHOULD_SKIP_THIS #ifndef DOXYGEN_SHOULD_SKIP_THIS
{ TidyEmacsFile, IR, "gnu-emacs-file", ST, 0, ParseString, NULL }, { TidyEmacsFile, IR, "gnu-emacs-file", ST, 0, ParseString, NULL },
#endif #endif
{ TidyEmptyTags, MU, "new-empty-tags", ST, 0, ParseTagNames, NULL }, { TidyEmptyTags, MU, "new-empty-tags", ST, 0, ParseTagNames, NULL },
{ TidyEncloseBlockText, MU, "enclose-block-text", BL, no, ParseBool, boolPicks }, { TidyEncloseBlockText, MU, "enclose-block-text", BL, no, ParsePickList, &boolPicks },
{ TidyEncloseBodyText, MU, "enclose-text", BL, no, ParseBool, boolPicks }, { TidyEncloseBodyText, MU, "enclose-text", BL, no, ParsePickList, &boolPicks },
{ TidyErrFile, MS, "error-file", ST, 0, ParseString, NULL }, { TidyErrFile, MS, "error-file", ST, 0, ParseString, NULL },
{ TidyEscapeCdata, MU, "escape-cdata", BL, no, ParseBool, boolPicks }, { TidyEscapeCdata, MU, "escape-cdata", BL, no, ParsePickList, &boolPicks },
{ TidyEscapeScripts, PP, "escape-scripts", BL, yes, ParseBool, boolPicks }, /* 20160227 - Issue #348 */ { TidyEscapeScripts, PP, "escape-scripts", BL, yes, ParsePickList, &boolPicks }, /* 20160227 - Issue #348 */
{ TidyFixBackslash, MU, "fix-backslash", BL, yes, ParseBool, boolPicks }, { TidyFixBackslash, MU, "fix-backslash", BL, yes, ParsePickList, &boolPicks },
{ TidyFixComments, MU, "fix-bad-comments", BL, yes, ParseBool, boolPicks }, { TidyFixComments, MU, "fix-bad-comments", BL, yes, ParsePickList, &boolPicks },
{ TidyFixUri, MU, "fix-uri", BL, yes, ParseBool, boolPicks }, { TidyFixUri, MU, "fix-uri", BL, yes, ParsePickList, &boolPicks },
{ TidyForceOutput, MS, "force-output", BL, no, ParseBool, boolPicks }, { TidyForceOutput, MS, "force-output", BL, no, ParsePickList, &boolPicks },
{ TidyGDocClean, MU, "gdoc", BL, no, ParseBool, boolPicks }, { TidyGDocClean, MU, "gdoc", BL, no, ParsePickList, &boolPicks },
{ TidyHideComments, MU, "hide-comments", BL, no, ParseBool, boolPicks }, { TidyHideComments, MU, "hide-comments", BL, no, ParsePickList, &boolPicks },
{ TidyHtmlOut, MU, "output-html", BL, no, ParseBool, boolPicks }, { TidyHtmlOut, MU, "output-html", BL, no, ParsePickList, &boolPicks },
{ TidyInCharEncoding, CE, "input-encoding", IN, UTF8, ParseCharEnc, charEncPicks }, { TidyInCharEncoding, CE, "input-encoding", IN, UTF8, ParseCharEnc, &charEncPicks },
{ TidyIndentAttributes, PP, "indent-attributes", BL, no, ParseBool, boolPicks }, { TidyIndentAttributes, PP, "indent-attributes", BL, no, ParsePickList, &boolPicks },
{ TidyIndentCdata, MU, "indent-cdata", BL, no, ParseBool, boolPicks }, { TidyIndentCdata, MU, "indent-cdata", BL, no, ParsePickList, &boolPicks },
{ TidyIndentContent, PP, "indent", IN, TidyNoState, ParseAutoBool, autoBoolPicks }, { TidyIndentContent, PP, "indent", IN, TidyNoState, ParsePickList, &autoBoolPicks },
{ TidyIndentSpaces, PP, "indent-spaces", IN, 2, ParseInt, NULL }, { TidyIndentSpaces, PP, "indent-spaces", IN, 2, ParseInt, NULL },
{ TidyInlineTags, MU, "new-inline-tags", ST, 0, ParseTagNames, NULL }, { TidyInlineTags, MU, "new-inline-tags", ST, 0, ParseTagNames, NULL },
{ TidyJoinClasses, MU, "join-classes", BL, no, ParseBool, boolPicks }, { TidyJoinClasses, MU, "join-classes", BL, no, ParsePickList, &boolPicks },
{ TidyJoinStyles, MU, "join-styles", BL, yes, ParseBool, boolPicks }, { TidyJoinStyles, MU, "join-styles", BL, yes, ParsePickList, &boolPicks },
{ TidyKeepFileTimes, MS, "keep-time", BL, no, ParseBool, boolPicks }, { TidyKeepFileTimes, MS, "keep-time", BL, no, ParsePickList, &boolPicks },
{ TidyLiteralAttribs, MU, "literal-attributes", BL, no, ParseBool, boolPicks }, { TidyLiteralAttribs, MU, "literal-attributes", BL, no, ParsePickList, &boolPicks },
{ TidyLogicalEmphasis, MU, "logical-emphasis", BL, no, ParseBool, boolPicks }, { TidyLogicalEmphasis, MU, "logical-emphasis", BL, no, ParsePickList, &boolPicks },
{ TidyLowerLiterals, MU, "lower-literals", BL, yes, ParseBool, boolPicks }, { TidyLowerLiterals, MU, "lower-literals", BL, yes, ParsePickList, &boolPicks },
{ TidyMakeBare, MU, "bare", BL, no, ParseBool, boolPicks }, { TidyMakeBare, MU, "bare", BL, no, ParsePickList, &boolPicks },
{ TidyMakeClean, MU, "clean", BL, no, ParseBool, boolPicks }, { TidyMakeClean, MU, "clean", BL, no, ParsePickList, &boolPicks },
{ TidyMark, MS, "tidy-mark", BL, yes, ParseBool, boolPicks }, { TidyMark, MS, "tidy-mark", BL, yes, ParsePickList, &boolPicks },
{ TidyMergeDivs, MU, "merge-divs", IN, TidyAutoState, ParseAutoBool, autoBoolPicks }, { TidyMergeDivs, MU, "merge-divs", IN, TidyAutoState, ParsePickList, &autoBoolPicks },
{ TidyMergeEmphasis, MU, "merge-emphasis", BL, yes, ParseBool, boolPicks }, { TidyMergeEmphasis, MU, "merge-emphasis", BL, yes, ParsePickList, &boolPicks },
{ TidyMergeSpans, MU, "merge-spans", IN, TidyAutoState, ParseAutoBool, autoBoolPicks }, { TidyMergeSpans, MU, "merge-spans", IN, TidyAutoState, ParsePickList, &autoBoolPicks },
#if SUPPORT_ASIAN_ENCODINGS #if SUPPORT_ASIAN_ENCODINGS
{ TidyNCR, MU, "ncr", BL, yes, ParseBool, boolPicks }, { TidyNCR, MU, "ncr", BL, yes, ParsePickList, &boolPicks },
#endif #endif
{ TidyNewline, CE, "newline", IN, DLF, ParseNewline, newlinePicks }, { TidyNewline, CE, "newline", IN, DLF, ParsePickList, &newlinePicks },
{ TidyNumEntities, MU, "numeric-entities", BL, no, ParseBool, boolPicks }, { TidyNumEntities, MU, "numeric-entities", BL, no, ParsePickList, &boolPicks },
{ TidyOmitOptionalTags, MU, "omit-optional-tags", BL, no, ParseBool, boolPicks }, { TidyOmitOptionalTags, MU, "omit-optional-tags", BL, no, ParsePickList, &boolPicks },
{ TidyOutCharEncoding, CE, "output-encoding", IN, UTF8, ParseCharEnc, charEncPicks }, { TidyOutCharEncoding, CE, "output-encoding", IN, UTF8, ParseCharEnc, &charEncPicks },
{ TidyOutFile, MS, "output-file", ST, 0, ParseString, NULL }, { TidyOutFile, MS, "output-file", ST, 0, ParseString, NULL },
#if SUPPORT_UTF16_ENCODINGS #if SUPPORT_UTF16_ENCODINGS
{ TidyOutputBOM, CE, "output-bom", IN, TidyAutoState, ParseAutoBool, autoBoolPicks }, { TidyOutputBOM, CE, "output-bom", IN, TidyAutoState, ParsePickList, &autoBoolPicks },
#endif #endif
{ TidyPPrintTabs, PP, "indent-with-tabs", BL, no, ParseTabs, boolPicks }, /* 20150515 - Issue #108 */ { TidyPPrintTabs, PP, "indent-with-tabs", BL, no, ParseTabs, &boolPicks }, /* 20150515 - Issue #108 */
{ TidyPreserveEntities, MU, "preserve-entities", BL, no, ParseBool, boolPicks }, { TidyPreserveEntities, MU, "preserve-entities", BL, no, ParsePickList, &boolPicks },
{ TidyPreTags, MU, "new-pre-tags", ST, 0, ParseTagNames, NULL }, { TidyPreTags, MU, "new-pre-tags", ST, 0, ParseTagNames, NULL },
#if SUPPORT_ASIAN_ENCODINGS #if SUPPORT_ASIAN_ENCODINGS
{ TidyPunctWrap, PP, "punctuation-wrap", BL, no, ParseBool, boolPicks }, { TidyPunctWrap, PP, "punctuation-wrap", BL, no, ParsePickList, &boolPicks },
#endif #endif
{ TidyQuiet, MS, "quiet", BL, no, ParseBool, boolPicks }, { TidyQuiet, MS, "quiet", BL, no, ParseBool, boolPicks },
{ TidyQuoteAmpersand, MU, "quote-ampersand", BL, yes, ParseBool, boolPicks }, { TidyQuoteAmpersand, MU, "quote-ampersand", BL, yes, ParseBool, boolPicks },
@ -340,6 +316,7 @@ static const TidyOptionImpl option_defs[] =
{ N_TIDY_OPTIONS, XX, NULL, XY, 0, NULL, NULL } { N_TIDY_OPTIONS, XX, NULL, XY, 0, NULL, NULL }
}; };
/* Should only be called by options set by name /* Should only be called by options set by name
** thus, it is cheaper to do a few scans than set ** thus, it is cheaper to do a few scans than set
** up every option in a hash table. ** up every option in a hash table.
@ -625,7 +602,7 @@ TidyTriState TY_(_cfgGetAutoBool)( TidyDocImpl* doc, TidyOptionId optId )
ulong val = TY_(_cfgGet)( doc, optId ); ulong val = TY_(_cfgGet)( doc, optId );
const TidyOptionImpl* opt = &option_defs[ optId ]; const TidyOptionImpl* opt = &option_defs[ optId ];
assert( opt && opt->type == TidyInteger assert( opt && opt->type == TidyInteger
&& opt->parser == ParseAutoBool ); && opt->parser == ParsePickList );
return (TidyTriState) val; return (TidyTriState) val;
} }
@ -1058,7 +1035,7 @@ void AdjustConfig( TidyDocImpl* doc )
{ {
TY_(SetOptionBool)( doc, TidyXmlOut, yes ); TY_(SetOptionBool)( doc, TidyXmlOut, yes );
TY_(SetOptionBool)( doc, TidyUpperCaseTags, no ); TY_(SetOptionBool)( doc, TidyUpperCaseTags, no );
TY_(SetOptionBool)( doc, TidyUpperCaseAttrs, no ); TY_(SetOptionInt)( doc, TidyUpperCaseAttrs, no );
/* TY_(SetOptionBool)( doc, TidyXmlPIs, yes ); */ /* TY_(SetOptionBool)( doc, TidyXmlPIs, yes ); */
} }
@ -1122,76 +1099,6 @@ Bool ParseInt( TidyDocImpl* doc, const TidyOptionImpl* entry )
return digits; return digits;
} }
/* true/false or yes/no or 0/1 or "auto" only looks at 1st char */
static Bool ParseTriState( TidyTriState theState, TidyDocImpl* doc,
const TidyOptionImpl* entry, ulong* flag )
{
TidyConfigImpl* cfg = &doc->config;
tchar c = SkipWhite( cfg );
if (c == 't' || c == 'T' || c == 'y' || c == 'Y' || c == '1')
*flag = yes;
else if (c == 'f' || c == 'F' || c == 'n' || c == 'N' || c == '0')
*flag = no;
else if (theState == TidyAutoState && (c == 'a' || c =='A'))
*flag = TidyAutoState;
else
{
TY_(ReportBadArgument)( doc, entry->name );
return no;
}
return yes;
}
/* cr, lf or crlf */
Bool ParseNewline( TidyDocImpl* doc, const TidyOptionImpl* entry )
{
int nl = -1;
tmbchar work[ 16 ] = {0};
tmbstr cp = work, end = work + sizeof(work);
TidyConfigImpl* cfg = &doc->config;
tchar c = SkipWhite( cfg );
while ( c!=EndOfStream && cp < end && !TY_(IsWhite)(c) && c != '\r' && c != '\n' )
{
*cp++ = (tmbchar) c;
c = AdvanceChar( cfg );
}
*cp = 0;
if ( TY_(tmbstrcasecmp)(work, "lf") == 0 )
nl = TidyLF;
else if ( TY_(tmbstrcasecmp)(work, "crlf") == 0 )
nl = TidyCRLF;
else if ( TY_(tmbstrcasecmp)(work, "cr") == 0 )
nl = TidyCR;
if ( nl < TidyLF || nl > TidyCR )
TY_(ReportBadArgument)( doc, entry->name );
else
TY_(SetOptionInt)( doc, entry->id, nl );
return ( nl >= TidyLF && nl <= TidyCR );
}
Bool ParseBool( TidyDocImpl* doc, const TidyOptionImpl* entry )
{
ulong flag = 0;
Bool status = ParseTriState( TidyNoState, doc, entry, &flag );
if ( status )
TY_(SetOptionBool)( doc, entry->id, flag != 0 );
return status;
}
Bool ParseAutoBool( TidyDocImpl* doc, const TidyOptionImpl* entry )
{
ulong flag = 0;
Bool status = ParseTriState( TidyAutoState, doc, entry, &flag );
if ( status )
TY_(SetOptionInt)( doc, entry->id, flag );
return status;
}
/* a string excluding whitespace */ /* a string excluding whitespace */
Bool FUNC_UNUSED ParseName( TidyDocImpl* doc, const TidyOptionImpl* option ) Bool FUNC_UNUSED ParseName( TidyDocImpl* doc, const TidyOptionImpl* option )
{ {
@ -1243,15 +1150,77 @@ Bool ParseCSS1Selector( TidyDocImpl* doc, const TidyOptionImpl* option )
return yes; return yes;
} }
/* A general parser for anything using pick lists. This provides the engine to
determine the proper option value, and can be used by parsers in addition to
ParsePickList that require special handling.
*/
Bool GetParsePickListValue( TidyDocImpl* doc, const TidyOptionImpl* entry, uint *result )
{
TidyConfigImpl* cfg = &doc->config;
tchar c = SkipWhite( cfg );
tmbchar work[ 16 ] = {0};
tmbstr cp = work, end = work + sizeof(work);
const PickListItem *item = NULL;
uint ix = 0;
while ( c!=EndOfStream && cp < end && !TY_(IsWhite)(c) && c != '\r' && c != '\n' )
{
*cp++ = (tmbchar) c;
c = AdvanceChar( cfg );
}
while ( (item = &(*entry->pickList)[ ix ]) && item->label )
{
ctmbstr input;
uint i = 0;
while ( ( input = &(*item->inputs[i]) ) )
{
if (TY_(tmbstrcasecmp)(work, input) == 0 )
{
*result = ix;
return yes;
}
++i;
}
++ix;
}
TY_(ReportBadArgument)( doc, entry->name );
return no;
}
/* A general parser for anything using pick lists that don't require special
handling.
*/
Bool ParsePickList( TidyDocImpl* doc, const TidyOptionImpl* entry )
{
uint value;
if ( GetParsePickListValue( doc, entry, &value ) )
{
if ( entry->type == TidyBoolean )
TY_(SetOptionBool)( doc, entry->id, value );
else if ( entry->type == TidyInteger )
TY_(SetOptionInt)( doc, entry->id, value );
return yes;
}
TY_(ReportBadArgument)( doc, entry->name );
return no;
}
/*\ /*\
* 20150515 - support using tabs instead of spaces - Issue #108 * 20150515 - support using tabs instead of spaces - Issue #108
* Sets the indent character to a tab if on, and set indent space count to 1 * Sets the indent character to a tab if on, and set indent space count to 1
* and sets indent character to a space if off. * and sets indent character to a space if off.
\*/ \*/
Bool ParseTabs( TidyDocImpl* doc, const TidyOptionImpl* entry ) Bool ParseTabs( TidyDocImpl* doc, const TidyOptionImpl* entry )
{ {
ulong flag = 0; uint flag = 0;
Bool status = ParseTriState( TidyNoState, doc, entry, &flag ); Bool status = GetParsePickListValue( doc, entry, &flag );
if ( status ) { if ( status ) {
Bool tabs = flag != 0 ? yes : no; Bool tabs = flag != 0 ? yes : no;
TY_(SetOptionBool)( doc, entry->id, tabs ); TY_(SetOptionBool)( doc, entry->id, tabs );
@ -1264,52 +1233,6 @@ Bool ParseTabs( TidyDocImpl* doc, const TidyOptionImpl* entry )
return status; return status;
} }
/* Parse the value of TidyUseCustomTags. Like other option values, we will
* look for the first character only, of no, blocklevel, empty, inline, pre.
*/
Bool ParseUseCustomTags( TidyDocImpl* doc, const TidyOptionImpl* entry )
{
uint value;
TidyConfigImpl* cfg = &doc->config;
tchar c = SkipWhite( cfg );
switch (c)
{
case 'n':
case 'N':
value = TidyCustomNo;
break;
case 'b':
value = TidyCustomBlocklevel;
break;
case 'e':
case 'E':
value = TidyCustomEmpty;
break;
case 'y':
case 'Y':
case 'i':
case 'I':
value = TidyCustomInline;
break;
case 'p':
case 'P':
value = TidyCustomPre;
break;
default:
TY_(ReportBadArgument)( doc, entry->name );
return no;
}
TY_(SetOptionInt)( doc, TidyUseCustomTags, value );
return yes;
}
/* Coordinates Config update and Tags data */ /* Coordinates Config update and Tags data */
void TY_(DeclareUserTag)( TidyDocImpl* doc, TidyOptionId optId, void TY_(DeclareUserTag)( TidyDocImpl* doc, TidyOptionId optId,
@ -1545,11 +1468,8 @@ ctmbstr TY_(CharEncodingOptName)( int encoding )
*/ */
Bool ParseDocType( TidyDocImpl* doc, const TidyOptionImpl* option ) Bool ParseDocType( TidyDocImpl* doc, const TidyOptionImpl* option )
{ {
tmbchar buf[ 32 ] = {0};
uint i = 0;
Bool status = yes; Bool status = yes;
TidyDoctypeModes dtmode = TidyDoctypeAuto; uint value;
TidyConfigImpl* cfg = &doc->config; TidyConfigImpl* cfg = &doc->config;
tchar c = SkipWhite( cfg ); tchar c = SkipWhite( cfg );
@ -1559,94 +1479,21 @@ Bool ParseDocType( TidyDocImpl* doc, const TidyOptionImpl* option )
{ {
status = ParseString(doc, option); status = ParseString(doc, option);
if (status) if (status)
{
TY_(SetOptionInt)( doc, TidyDoctypeMode, TidyDoctypeUser ); TY_(SetOptionInt)( doc, TidyDoctypeMode, TidyDoctypeUser );
}
return status; return status;
} }
/* read first word */ if ( (status = GetParsePickListValue( doc, option, &value ) ) )
while ( i < sizeof(buf)-1 && c != EndOfStream && !TY_(IsWhite)(c) )
{ {
buf[i++] = (tmbchar) c; TY_(SetOptionInt)( doc, TidyDoctypeMode, value );
c = AdvanceChar( cfg );
} }
buf[i] = '\0';
if ( TY_(tmbstrcasecmp)(buf, "auto") == 0 )
dtmode = TidyDoctypeAuto;
else if ( TY_(tmbstrcasecmp)(buf, "html5") == 0 )
dtmode = TidyDoctypeHtml5;
else if ( TY_(tmbstrcasecmp)(buf, "omit") == 0 )
dtmode = TidyDoctypeOmit;
else if ( TY_(tmbstrcasecmp)(buf, "strict") == 0 )
dtmode = TidyDoctypeStrict;
else if ( TY_(tmbstrcasecmp)(buf, "loose") == 0 ||
TY_(tmbstrcasecmp)(buf, "transitional") == 0 )
dtmode = TidyDoctypeLoose;
else else
{ {
TY_(ReportBadArgument)( doc, option->name ); TY_(ReportBadArgument)( doc, option->name );
status = no;
}
if ( status )
TY_(SetOptionInt)( doc, TidyDoctypeMode, dtmode );
return status;
}
Bool ParseRepeatAttr( TidyDocImpl* doc, const TidyOptionImpl* option )
{
Bool status = yes;
tmbchar buf[64] = {0};
uint i = 0;
TidyConfigImpl* cfg = &doc->config;
tchar c = SkipWhite( cfg );
while (i < sizeof(buf)-1 && c != EndOfStream && !TY_(IsWhite)(c))
{
buf[i++] = (tmbchar) c;
c = AdvanceChar( cfg );
}
buf[i] = '\0';
if ( TY_(tmbstrcasecmp)(buf, "keep-first") == 0 )
cfg->value[ TidyDuplicateAttrs ].v = TidyKeepFirst;
else if ( TY_(tmbstrcasecmp)(buf, "keep-last") == 0 )
cfg->value[ TidyDuplicateAttrs ].v = TidyKeepLast;
else
{
TY_(ReportBadArgument)( doc, option->name );
status = no;
}
return status;
}
Bool ParseSorter( TidyDocImpl* doc, const TidyOptionImpl* option )
{
Bool status = yes;
tmbchar buf[64] = {0};
uint i = 0;
TidyConfigImpl* cfg = &doc->config;
tchar c = SkipWhite( cfg );
while (i < sizeof(buf)-1 && c != EndOfStream && !TY_(IsWhite)(c))
{
buf[i++] = (tmbchar) c;
c = AdvanceChar( cfg );
}
buf[i] = '\0';
if ( TY_(tmbstrcasecmp)(buf, "alpha") == 0 )
cfg->value[ TidySortAttributes ].v = TidySortAttrAlpha;
else if ( TY_(tmbstrcasecmp)(buf, "none") == 0)
cfg->value[ TidySortAttributes ].v = TidySortAttrNone;
else
{
TY_(ReportBadArgument)( doc, option->name );
status = no;
} }
return status; return status;
} }
@ -1692,12 +1539,22 @@ ctmbstr TY_(getNextOptionPick)( const TidyOptionImpl* option,
{ {
size_t ix; size_t ix;
ctmbstr val = NULL; ctmbstr val = NULL;
const PickListItem *item= NULL;
assert( option!=NULL && iter != NULL ); assert( option!=NULL && iter != NULL );
ix = (size_t) *iter; ix = (size_t) *iter;
if ( ix > 0 && ix < 16 && option->pickList )
val = option->pickList[ ix-1 ]; if ( option->pickList )
*iter = (TidyIterator) ( val && option->pickList[ix] ? ix + 1 : (size_t)0 ); {
if ( ix > 0 && ix < TIDY_PL_SIZE && option->pickList )
{
item = &(*option->pickList)[ ix-1 ];
val = item->label;
}
item = &(*option->pickList)[ ix ];
*iter = (TidyIterator) ( val && item->label ? ix + 1 : (size_t)0 );
}
return val; return val;
} }
@ -1731,12 +1588,19 @@ static int WriteOptionBool( const TidyOptionImpl* option, Bool bval, StreamOut*
static int WriteOptionPick( const TidyOptionImpl* option, uint ival, StreamOut* out ) static int WriteOptionPick( const TidyOptionImpl* option, uint ival, StreamOut* out )
{ {
uint ix; uint ix = 0;
const ctmbstr* val = option->pickList; const PickListItem *item = NULL;
for ( ix=0; val[ix] && ix<ival; ++ix )
/**/; if ( option-> pickList )
if ( ix==ival && val[ix] ) {
return WriteOptionString( option, val[ix], out ); while ( (item = &(*option->pickList)[ ix ]) && item->label && ix<ival )
{
++ix;
}
if ( ix==ival && item->label )
return WriteOptionString( option, item->label, out );
}
return -1; return -1;
} }
@ -1796,7 +1660,7 @@ static int SaveConfigToStream( TidyDocImpl* doc, StreamOut* out )
else else
rc = WriteOptionPick( option, dtmode, out ); rc = WriteOptionPick( option, dtmode, out );
} }
else if ( option->pickList ) else if ( option->pickList)
rc = WriteOptionPick( option, val->v, out ); rc = WriteOptionPick( option, val->v, out );
else else
{ {

View file

@ -1,30 +1,65 @@
#ifndef __CONFIG_H__ #ifndef __CONFIG_H__
#define __CONFIG_H__ #define __CONFIG_H__
/* config.h -- read config file and manage config properties /**************************************************************************//**
* @file
(c) 1998-2006 (W3C) MIT, ERCIM, Keio University * Read configuration files and manage configuration properties.
See tidy.h for the copyright notice. *
* Config files associate a property name with a value.
config files associate a property name with a value. *
* // comments can start at the beginning of a line
// comments can start at the beginning of a line * # comments can start at the beginning of a line
# comments can start at the beginning of a line * name: short values fit onto one line
name: short values fit onto one line * name: a really long value that
name: a really long value that * continues on the next line
continues on the next line *
* Property names are case insensitive and should be less than 60 characters
property names are case insensitive and should be less than * in length, and must start at the begining of the line, as whitespace at
60 characters in length and must start at the begining of * the start of a line signifies a line continuation.
the line, as whitespace at the start of a line signifies a *
line continuation. * @author HTACG, et al (consult git log)
*
*/ * @copyright
* Copyright (c) 1998-2017 World Wide Web Consortium (Massachusetts
* Institute of Technology, European Research Consortium for Informatics
* and Mathematics, Keio University) and HTACG.
* @par
* All Rights Reserved.
* @par
* See `tidy.h` for the complete license.
*
* @date Additional updates: consult git log
*
******************************************************************************/
#include "forward.h" #include "forward.h"
#include "tidy.h" #include "tidy.h"
#include "streamio.h" #include "streamio.h"
/** PickLists may have up to 16 items. For some reason,
** this limit has always been hard-coded into Tidy.
*/
#define TIDY_PL_SIZE 16
/** Structs of this type contain information needed in order to present pick lists,
** relate pick list entries to public enum values, and parse strings that are
** accepted in order to assign the value.
*/
typedef struct PickListItem {
ctmbstr label; /**< PickList label for this item. */
const int value; /**< The option value represented by this label. */
ctmbstr inputs[10]; /**< String values that can select this value. */
} PickListItem;
/** An array of PickListItems, fixed in size for in-code declarations.
** Arrays must be populated in 0 to 10 order, as the option value is assigned
** based on this index and *not* on the structures' value field. It remains
** a best practice, however, to assign a public enum value with the proper
** index value.
*/
typedef const PickListItem PickListItems[TIDY_PL_SIZE];
struct _tidy_option; struct _tidy_option;
typedef struct _tidy_option TidyOptionImpl; typedef struct _tidy_option TidyOptionImpl;
@ -33,13 +68,13 @@ typedef Bool (ParseProperty)( TidyDocImpl* doc, const TidyOptionImpl* opt );
struct _tidy_option struct _tidy_option
{ {
TidyOptionId id; TidyOptionId id;
TidyConfigCategory category; /* put 'em in groups */ TidyConfigCategory category; /* put 'em in groups */
ctmbstr name; /* property name */ ctmbstr name; /* property name */
TidyOptionType type; /* string, int or bool */ TidyOptionType type; /* string, int or bool */
ulong dflt; /* default for TidyInteger and TidyBoolean */ ulong dflt; /* default for TidyInteger and TidyBoolean */
ParseProperty* parser; /* parsing method, read-only if NULL */ ParseProperty* parser; /* parsing method, read-only if NULL */
const ctmbstr* pickList; /* pick list */ PickListItems* pickList; /* new style pick list */
ctmbstr pdflt; /* default for TidyString */ ctmbstr pdflt; /* default for TidyString */
}; };
typedef union typedef union

View file

@ -1202,8 +1202,12 @@ static languageDefinition language_en = { whichPluralForm_en, {
"This option specifies if Tidy should output attribute names in upper " "This option specifies if Tidy should output attribute names in upper "
"case. " "case. "
"<br/>" "<br/>"
"The default is <var>no</var>, which results in lower case attribute " "When set to <var>no</var>, attribute names will be written in lower "
"names, except for XML input, where the original case is preserved. " "case. Specifying <var>yes</var> will output attribute names in upper "
"case, and <var>preserve</var> can used to leave attribute names "
"untouched. "
"<br/>"
"When using XML input, the original case is always preserved. "
}, },
{/* Important notes for translators: {/* Important notes for translators:
- Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and - Use only <code></code>, <var></var>, <em></em>, <strong></strong>, and

View file

@ -28,7 +28,7 @@
* *
* Orginating PO file metadata: * Orginating PO file metadata:
* PO_LAST_TRANSLATOR=jderry * PO_LAST_TRANSLATOR=jderry
* PO_REVISION_DATE=2017-03-22 15:54:52 * PO_REVISION_DATE=2017-05-13 21:04:45
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER

View file

@ -28,7 +28,7 @@
* *
* Orginating PO file metadata: * Orginating PO file metadata:
* PO_LAST_TRANSLATOR=jderry * PO_LAST_TRANSLATOR=jderry
* PO_REVISION_DATE=2017-03-22 15:54:52 * PO_REVISION_DATE=2017-05-13 21:04:45
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER

View file

@ -28,7 +28,7 @@
* *
* Orginating PO file metadata: * Orginating PO file metadata:
* PO_LAST_TRANSLATOR=jderry * PO_LAST_TRANSLATOR=jderry
* PO_REVISION_DATE=2017-03-22 15:54:52 * PO_REVISION_DATE=2017-05-13 21:04:45
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER

File diff suppressed because it is too large Load diff

View file

@ -28,7 +28,7 @@
* *
* Orginating PO file metadata: * Orginating PO file metadata:
* PO_LAST_TRANSLATOR=jderry * PO_LAST_TRANSLATOR=jderry
* PO_REVISION_DATE=2017-03-22 15:54:52 * PO_REVISION_DATE=2017-05-13 21:04:45
*/ */
#ifdef _MSC_VER #ifdef _MSC_VER

View file

@ -3723,11 +3723,30 @@ static tmbstr ParseAttribute( TidyDocImpl* doc, Bool *isempty,
if (TY_(IsWhite)(c)) if (TY_(IsWhite)(c))
break; break;
if (c == '/') /* Issue #395 - potential self closing tag */
{
c = TY_(ReadChar)(doc->docIn); /* read next */
if (c == '>')
{
/* got a self closing tag - put is back and continue... */
TY_(UngetChar)(c, doc->docIn);
break;
}
else
{
/* Not '/>' - put it back */
TY_(UngetChar)(c, doc->docIn);
}
}
/* what should be done about non-namechar characters? */ /* what should be done about non-namechar characters? */
/* currently these are incorporated into the attr name */ /* currently these are incorporated into the attr name */
if ( !cfgBool(doc, TidyXmlTags) && TY_(IsUpper)(c) ) if ( cfg(doc, TidyUpperCaseAttrs) != TidyUppercasePreserve )
c = TY_(ToLower)(c); {
if ( !cfgBool(doc, TidyXmlTags) && TY_(IsUpper)(c) )
c = TY_(ToLower)(c);
}
TY_(AddCharToLexer)( lexer, c ); TY_(AddCharToLexer)( lexer, c );
lastc = c; lastc = c;

View file

@ -243,6 +243,7 @@ void TY_(ReportNotice)(TidyDocImpl* doc, Node *element, Node *node, uint code)
tagtype = tidyLocalizedString( TIDYCUSTOMINLINE_STRING ); tagtype = tidyLocalizedString( TIDYCUSTOMINLINE_STRING );
break; break;
case TidyCustomPre: case TidyCustomPre:
default:
tagtype = tidyLocalizedString( TIDYCUSTOMPRE_STRING ); tagtype = tidyLocalizedString( TIDYCUSTOMPRE_STRING );
break; break;
} }

View file

@ -4833,7 +4833,7 @@ void TY_(ParseDocument)(TidyDocImpl* doc)
if ( !htmlOut ) if ( !htmlOut )
{ {
TY_(SetOptionBool)( doc, TidyUpperCaseTags, no ); TY_(SetOptionBool)( doc, TidyUpperCaseTags, no );
TY_(SetOptionBool)( doc, TidyUpperCaseAttrs, no ); TY_(SetOptionInt)( doc, TidyUpperCaseAttrs, no );
} }
} }
} }

View file

@ -1238,7 +1238,7 @@ static void PPrintAttribute( TidyDocImpl* doc, uint indent,
Bool xmlOut = cfgBool( doc, TidyXmlOut ); Bool xmlOut = cfgBool( doc, TidyXmlOut );
Bool xhtmlOut = cfgBool( doc, TidyXhtmlOut ); Bool xhtmlOut = cfgBool( doc, TidyXhtmlOut );
Bool wrapAttrs = cfgBool( doc, TidyWrapAttVals ); Bool wrapAttrs = cfgBool( doc, TidyWrapAttVals );
Bool ucAttrs = cfgBool( doc, TidyUpperCaseAttrs ); uint ucAttrs = cfg( doc, TidyUpperCaseAttrs );
Bool indAttrs = cfgBool( doc, TidyIndentAttributes ); Bool indAttrs = cfgBool( doc, TidyIndentAttributes );
uint xtra = AttrIndent( doc, node, attr ); uint xtra = AttrIndent( doc, node, attr );
Bool first = AttrNoIndentFirst( /*doc,*/ node, attr ); Bool first = AttrNoIndentFirst( /*doc,*/ node, attr );
@ -1287,7 +1287,7 @@ static void PPrintAttribute( TidyDocImpl* doc, uint indent,
if (c > 0x7F) if (c > 0x7F)
name += TY_(GetUTF8)(name, &c); name += TY_(GetUTF8)(name, &c);
else if (ucAttrs) else if (ucAttrs == TidyUppercaseYes)
c = TY_(ToUpper)(c); c = TY_(ToUpper)(c);
AddChar(pprint, c); AddChar(pprint, c);
@ -1734,8 +1734,8 @@ static void PPrintXmlDecl( TidyDocImpl* doc, uint indent, Node *node )
saveWrap = WrapOff( doc ); saveWrap = WrapOff( doc );
/* no case translation for XML declaration pseudo attributes */ /* no case translation for XML declaration pseudo attributes */
ucAttrs = cfgBool(doc, TidyUpperCaseAttrs); ucAttrs = cfg(doc, TidyUpperCaseAttrs);
TY_(SetOptionBool)(doc, TidyUpperCaseAttrs, no); TY_(SetOptionInt)(doc, TidyUpperCaseAttrs, no);
AddString( pprint, "<?xml" ); AddString( pprint, "<?xml" );
@ -1749,7 +1749,7 @@ static void PPrintXmlDecl( TidyDocImpl* doc, uint indent, Node *node )
PPrintAttribute( doc, indent, node, att ); PPrintAttribute( doc, indent, node, att );
/* restore old config value */ /* restore old config value */
TY_(SetOptionBool)(doc, TidyUpperCaseAttrs, ucAttrs); TY_(SetOptionInt)(doc, TidyUpperCaseAttrs, ucAttrs);
if ( node->end <= 0 || doc->lexer->lexbuf[node->end - 1] != '?' ) if ( node->end <= 0 || doc->lexer->lexbuf[node->end - 1] != '?' )
AddChar( pprint, '?' ); AddChar( pprint, '?' );
@ -1935,6 +1935,8 @@ static Bool TY_(nodeIsTextLike)( Node *node )
return yes; return yes;
if ( node->type == AspTag ) if ( node->type == AspTag )
return yes; return yes;
if (node->type == PhpTag)
return yes; /* Issue #392 */
/* add other text like nodes... */ /* add other text like nodes... */
return no; return no;
} }

View file

@ -476,15 +476,22 @@ ctmbstr TIDY_CALL tidyOptGetEncName( TidyDoc tdoc, TidyOptionId optId )
ctmbstr TIDY_CALL tidyOptGetCurrPick( TidyDoc tdoc, TidyOptionId optId ) ctmbstr TIDY_CALL tidyOptGetCurrPick( TidyDoc tdoc, TidyOptionId optId )
{ {
const TidyOptionImpl* option = TY_(getOption)( optId ); const TidyOptionImpl* option = TY_(getOption)( optId );
if ( option && option->pickList ) if ( option && option->pickList )
{ {
uint ix, pick = tidyOptGetInt( tdoc, optId ); uint ix = 0;
const ctmbstr* pL = option->pickList; uint pick = tidyOptGetInt( tdoc, optId );
for ( ix=0; *pL && ix < pick; ++ix ) const PickListItem *item = NULL;
++pL;
if ( *pL ) // loop through the picklist until index matches the value
return *pL; while ( (item = &(*option->pickList)[ ix ]) && item->label && ix<pick )
{
++ix;
}
if ( ix==pick && item->label )
return item->label;
} }
return NULL; return NULL;
} }

View file

@ -1,2 +1,2 @@
5.5.21 5.5.29
2017.05.07 2017.05.27