diff --git a/include/tidyenum.h b/include/tidyenum.h index f494afb..d3c34f3 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -172,6 +172,7 @@ typedef enum TidySkipNested, /**< Skip nested tags in script and style CDATA */ TidyStrictTagsAttr, /**< Ensure tags and attributes match output HTML version */ 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 */ } TidyOptionId; diff --git a/src/config.c b/src/config.c index ddb677c..f040c96 100644 --- a/src/config.c +++ b/src/config.c @@ -324,6 +324,7 @@ static const TidyOptionImpl option_defs[] = { TidySkipNested, MU, "skip-nested", BL, yes, ParseBool, boolPicks }, /* 1642186 - Issue #65 */ { TidyStrictTagsAttr, MU, "strict-tags-attributes", BL, no, ParseBool, boolPicks }, /* 20160209 - Issue #350 */ { 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 } }; diff --git a/src/language_en.h b/src/language_en.h index 7a8d1de..316ec09 100644 --- a/src/language_en.h +++ b/src/language_en.h @@ -2080,6 +2080,18 @@ static languageDefinition language_en = { whichPluralForm_en, { "This option causes items that look like closing tags, like </g to be escaped " "to <\\/g. Set this option to 'no' if you do not want this." }, + {/* Important notes for translators: + - Use only , , , , and +
. + - Entities, tags, attributes, etc., should be enclosed in . + - Option values should be enclosed in . + - It's very important that
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 diff --git a/src/lexer.c b/src/lexer.c index 6c22085..ffc4394 100644 --- a/src/lexer.c +++ b/src/lexer.c @@ -1674,6 +1674,16 @@ Node *TY_(FindBody)( TidyDocImpl* doc ) 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 */ Bool TY_(AddGenerator)( TidyDocImpl* doc ) { diff --git a/src/lexer.h b/src/lexer.h index 0c8d5bb..e390e7a 100644 --- a/src/lexer.h +++ b/src/lexer.h @@ -491,6 +491,9 @@ Node* TY_(FindXmlDecl)(TidyDocImpl* doc); /* Returns containing block element, if any */ Node* TY_(FindContainer)( Node* node ); +/* Adds meta element and sets the charset */ +Bool TY_(TidyMetaCharset)( TidyDocImpl* doc ); + /* add meta element for Tidy */ Bool TY_(AddGenerator)( TidyDocImpl* doc ); diff --git a/src/tidylib.c b/src/tidylib.c index 4787336..4753ab1 100755 --- a/src/tidylib.c +++ b/src/tidylib.c @@ -1795,6 +1795,7 @@ int tidyDocCleanAndRepair( TidyDocImpl* doc ) Bool xhtmlOut = cfgBool( doc, TidyXhtmlOut ); Bool xmlDecl = cfgBool( doc, TidyXmlDecl ); Bool tidyMark = cfgBool( doc, TidyMark ); + Bool tidyMetaCharset = cfgBool( doc, TidyMetaCharset); Bool tidyXmlTags = cfgBool( doc, TidyXmlTags ); Bool wantNameAttr = cfgBool( doc, TidyAnchorAsName ); Bool mergeEmphasis = cfgBool( doc, TidyMergeEmphasis ); @@ -1898,6 +1899,9 @@ int tidyDocCleanAndRepair( TidyDocImpl* doc ) if (tidyMark ) TY_(AddGenerator)(doc); + + if (tidyMetaCharset) + TY_(TidyMetaCharset)(doc); } /* ensure presence of initial */