Part 1 - Add basic infra for 'add-meta-charset' option
This commit is contained in:
parent
92a872251b
commit
169bd38adf
|
@ -172,6 +172,7 @@ typedef enum
|
||||||
TidySkipNested, /**< Skip nested tags in script and style CDATA */
|
TidySkipNested, /**< Skip nested tags in script and style CDATA */
|
||||||
TidyStrictTagsAttr, /**< Ensure tags and attributes match output HTML version */
|
TidyStrictTagsAttr, /**< Ensure tags and attributes match output HTML version */
|
||||||
TidyEscapeScripts, /**< Escape items that look like closing tags in script tags */
|
TidyEscapeScripts, /**< Escape items that look like closing tags in script tags */
|
||||||
|
TidyMetaCharset, /**< Adds/checks/fixes meta charset in the head, based on document type */
|
||||||
N_TIDY_OPTIONS /**< Must be last */
|
N_TIDY_OPTIONS /**< Must be last */
|
||||||
} TidyOptionId;
|
} TidyOptionId;
|
||||||
|
|
||||||
|
|
|
@ -324,6 +324,7 @@ static const TidyOptionImpl option_defs[] =
|
||||||
{ TidySkipNested, MU, "skip-nested", BL, yes, ParseBool, boolPicks }, /* 1642186 - Issue #65 */
|
{ TidySkipNested, MU, "skip-nested", BL, yes, ParseBool, boolPicks }, /* 1642186 - Issue #65 */
|
||||||
{ TidyStrictTagsAttr, MU, "strict-tags-attributes", BL, no, ParseBool, boolPicks }, /* 20160209 - Issue #350 */
|
{ TidyStrictTagsAttr, MU, "strict-tags-attributes", BL, no, ParseBool, boolPicks }, /* 20160209 - Issue #350 */
|
||||||
{ TidyEscapeScripts, PP, "escape-scripts", BL, yes, ParseBool, boolPicks }, /* 20160227 - Issue #348 */
|
{ TidyEscapeScripts, PP, "escape-scripts", BL, yes, ParseBool, boolPicks }, /* 20160227 - Issue #348 */
|
||||||
|
{ TidyMetaCharset, MS, "add-meta-charset", BL, yes, ParseBool, boolPicks }, /* 20161004 - Issue #456 */
|
||||||
{ N_TIDY_OPTIONS, XX, NULL, XY, 0, NULL, NULL }
|
{ N_TIDY_OPTIONS, XX, NULL, XY, 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2080,6 +2080,18 @@ static languageDefinition language_en = { whichPluralForm_en, {
|
||||||
"This option causes items that look like closing tags, like <code></g</code> to be escaped "
|
"This option causes items that look like closing tags, like <code></g</code> to be escaped "
|
||||||
"to <code><\\/g</code>. Set this option to 'no' if you do not want this."
|
"to <code><\\/g</code>. Set this option to 'no' if you do not want this."
|
||||||
},
|
},
|
||||||
|
{/* 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. */
|
||||||
|
TidyMetaCharset, 0,
|
||||||
|
"This option adds a meta element and sets the charset attribute to the encoding of the document."
|
||||||
|
"Set this option to 'yes' if you want this."
|
||||||
|
},
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
** Console Application
|
** Console Application
|
||||||
|
|
10
src/lexer.c
10
src/lexer.c
|
@ -1674,6 +1674,16 @@ Node *TY_(FindBody)( TidyDocImpl* doc )
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check meta charset*/
|
||||||
|
Bool TY_(TidyMetaCharset)( TidyDocImpl* doc )
|
||||||
|
{
|
||||||
|
AttVal *attval;
|
||||||
|
Node *node;
|
||||||
|
Node *head = TY_(FindHEAD)( doc );
|
||||||
|
printf("hello");
|
||||||
|
return no;
|
||||||
|
}
|
||||||
|
|
||||||
/* add meta element for Tidy */
|
/* add meta element for Tidy */
|
||||||
Bool TY_(AddGenerator)( TidyDocImpl* doc )
|
Bool TY_(AddGenerator)( TidyDocImpl* doc )
|
||||||
{
|
{
|
||||||
|
|
|
@ -491,6 +491,9 @@ Node* TY_(FindXmlDecl)(TidyDocImpl* doc);
|
||||||
/* Returns containing block element, if any */
|
/* Returns containing block element, if any */
|
||||||
Node* TY_(FindContainer)( Node* node );
|
Node* TY_(FindContainer)( Node* node );
|
||||||
|
|
||||||
|
/* Adds meta element and sets the charset */
|
||||||
|
Bool TY_(TidyMetaCharset)( TidyDocImpl* doc );
|
||||||
|
|
||||||
/* add meta element for Tidy */
|
/* add meta element for Tidy */
|
||||||
Bool TY_(AddGenerator)( TidyDocImpl* doc );
|
Bool TY_(AddGenerator)( TidyDocImpl* doc );
|
||||||
|
|
||||||
|
|
|
@ -1795,6 +1795,7 @@ int tidyDocCleanAndRepair( TidyDocImpl* doc )
|
||||||
Bool xhtmlOut = cfgBool( doc, TidyXhtmlOut );
|
Bool xhtmlOut = cfgBool( doc, TidyXhtmlOut );
|
||||||
Bool xmlDecl = cfgBool( doc, TidyXmlDecl );
|
Bool xmlDecl = cfgBool( doc, TidyXmlDecl );
|
||||||
Bool tidyMark = cfgBool( doc, TidyMark );
|
Bool tidyMark = cfgBool( doc, TidyMark );
|
||||||
|
Bool tidyMetaCharset = cfgBool( doc, TidyMetaCharset);
|
||||||
Bool tidyXmlTags = cfgBool( doc, TidyXmlTags );
|
Bool tidyXmlTags = cfgBool( doc, TidyXmlTags );
|
||||||
Bool wantNameAttr = cfgBool( doc, TidyAnchorAsName );
|
Bool wantNameAttr = cfgBool( doc, TidyAnchorAsName );
|
||||||
Bool mergeEmphasis = cfgBool( doc, TidyMergeEmphasis );
|
Bool mergeEmphasis = cfgBool( doc, TidyMergeEmphasis );
|
||||||
|
@ -1898,6 +1899,9 @@ int tidyDocCleanAndRepair( TidyDocImpl* doc )
|
||||||
|
|
||||||
if (tidyMark )
|
if (tidyMark )
|
||||||
TY_(AddGenerator)(doc);
|
TY_(AddGenerator)(doc);
|
||||||
|
|
||||||
|
if (tidyMetaCharset)
|
||||||
|
TY_(TidyMetaCharset)(doc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ensure presence of initial <?xml version="1.0"?> */
|
/* ensure presence of initial <?xml version="1.0"?> */
|
||||||
|
|
Loading…
Reference in a new issue