Initial take on issue 365. This is based off of the simplification of the
parser and picklist system. Console application needs to be updated to fix the description, as it shows autobool, and for some reason on the current system I'm not getting assertion failures.
This commit is contained in:
parent
1ba4bcb753
commit
29766afcfd
|
@ -786,6 +786,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
|
||||||
|
|
10
src/config.c
10
src/config.c
|
@ -138,6 +138,14 @@ static PickListItems customTagsPicks = {
|
||||||
{ 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
|
||||||
|
@ -284,7 +292,7 @@ static const TidyOptionImpl option_defs[] =
|
||||||
{ TidySortAttributes, PP, "sort-attributes", IN, TidySortAttrNone,ParsePickList, &sorterPicks },
|
{ TidySortAttributes, PP, "sort-attributes", IN, TidySortAttrNone,ParsePickList, &sorterPicks },
|
||||||
{ TidyStrictTagsAttr, MU, "strict-tags-attributes", BL, no, ParsePickList, &boolPicks }, /* 20160209 - Issue #350 */
|
{ TidyStrictTagsAttr, MU, "strict-tags-attributes", BL, no, ParsePickList, &boolPicks }, /* 20160209 - Issue #350 */
|
||||||
{ TidyTabSize, PP, "tab-size", IN, 8, ParseInt, NULL },
|
{ TidyTabSize, PP, "tab-size", IN, 8, ParseInt, NULL },
|
||||||
{ TidyUpperCaseAttrs, MU, "uppercase-attributes", BL, no, ParsePickList, &boolPicks },
|
{ TidyUpperCaseAttrs, MU, "uppercase-attributes", IN, no, ParsePickList, &attributeCasePicks },
|
||||||
{ TidyUpperCaseTags, MU, "uppercase-tags", BL, no, ParsePickList, &boolPicks },
|
{ TidyUpperCaseTags, MU, "uppercase-tags", BL, no, ParsePickList, &boolPicks },
|
||||||
{ TidyUseCustomTags, MU, "custom-tags", IN, TidyCustomNo, ParsePickList, &customTagsPicks }, /* 20170309 - Issue #119 */
|
{ TidyUseCustomTags, MU, "custom-tags", IN, TidyCustomNo, ParsePickList, &customTagsPicks }, /* 20170309 - Issue #119 */
|
||||||
{ TidyVertSpace, PP, "vertical-space", IN, no, ParsePickList, &autoBoolPicks }, /* #228 - tri option */
|
{ TidyVertSpace, PP, "vertical-space", IN, no, ParsePickList, &autoBoolPicks }, /* #228 - tri option */
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -3726,8 +3726,11 @@ static tmbstr ParseAttribute( TidyDocImpl* doc, Bool *isempty,
|
||||||
/* 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 ( cfg(doc, TidyUpperCaseAttrs) != TidyUppercasePreserve )
|
||||||
|
{
|
||||||
if ( !cfgBool(doc, TidyXmlTags) && TY_(IsUpper)(c) )
|
if ( !cfgBool(doc, TidyXmlTags) && TY_(IsUpper)(c) )
|
||||||
c = TY_(ToLower)(c);
|
c = TY_(ToLower)(c);
|
||||||
|
}
|
||||||
|
|
||||||
TY_(AddCharToLexer)( lexer, c );
|
TY_(AddCharToLexer)( lexer, c );
|
||||||
lastc = c;
|
lastc = c;
|
||||||
|
|
|
@ -4832,8 +4832,8 @@ void TY_(ParseDocument)(TidyDocImpl* doc)
|
||||||
/* adjust other config options, just as in config.c */
|
/* adjust other config options, just as in config.c */
|
||||||
if ( !htmlOut )
|
if ( !htmlOut )
|
||||||
{
|
{
|
||||||
TY_(SetOptionBool)( doc, TidyUpperCaseTags, no );
|
TY_(SetOptionInt)( doc, TidyUpperCaseTags, no );
|
||||||
TY_(SetOptionBool)( doc, TidyUpperCaseAttrs, no );
|
TY_(SetOptionInt)( doc, TidyUpperCaseAttrs, no );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
10
src/pprint.c
10
src/pprint.c
|
@ -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 = cfgBool( 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, '?' );
|
||||||
|
|
Loading…
Reference in a new issue