From df3bde38ecef7fa0d04c440daf3b7d90aa67dfe8 Mon Sep 17 00:00:00 2001 From: Jim Derry Date: Mon, 25 Sep 2017 15:26:03 -0400 Subject: [PATCH] Introduced `auto` behavior to the `fix-bad-comments` option so that `yes` or `no` could be applied automatically per the document type. This is the new default. --- localize/translations/tidy.pot | 6 ++++-- src/config.c | 8 ++++---- src/language_en.h | 4 +++- src/lexer.c | 17 ++++++++++++++++- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/localize/translations/tidy.pot b/localize/translations/tidy.pot index 3201df1..145b595 100644 --- a/localize/translations/tidy.pot +++ b/localize/translations/tidy.pot @@ -5,7 +5,7 @@ msgstr "" "Plural-Forms: nplurals=2; plural=n != 1;\n" "X-Generator: HTML Tidy poconvert.rb\n" "Project-Id-Version: \n" -"POT-Creation-Date: 2017-09-24 18:12:27\n" +"POT-Creation-Date: 2017-09-25 15:18:12\n" "Last-Translator: jderry\n" "Language-Team: \n" @@ -466,7 +466,9 @@ msgid "" "This option specifies if Tidy should replace unexpected hyphens with " "= characters when it comes across adjacent hyphens. " "
" -"The default is no. " +"The default is auto will which will act as no " +"for HTML5 document types, and yes for all other document " +"types. " "
" "HTML has abandonded SGML comment syntax, and allows adjacent hypens " "for all versions of HTML, although XML and XHTML do not. If you plan " diff --git a/src/config.c b/src/config.c index 9a27b37..1b540f8 100644 --- a/src/config.c +++ b/src/config.c @@ -59,9 +59,9 @@ static PickListItems boolPicks = { }; static PickListItems autoBoolPicks = { - { "no", TidyNoState, { "0", "n", "f", "no", "false", NULL } }, - { "yes", TidyYesState, { "1", "y", "t", "yes", "true", NULL } }, - { "auto", TidyYesState, { "auto", NULL } }, + { "no", TidyNoState, { "0", "n", "f", "no", "false", NULL } }, + { "yes", TidyYesState, { "1", "y", "t", "yes", "true", NULL } }, + { "auto", TidyAutoState, { "auto", NULL } }, { NULL } }; @@ -241,7 +241,7 @@ static const TidyOptionImpl option_defs[] = { TidyEscapeCdata, MU, "escape-cdata", BL, no, ParsePickList, &boolPicks }, { TidyEscapeScripts, PP, "escape-scripts", BL, yes, ParsePickList, &boolPicks }, /* 20160227 - Issue #348 */ { TidyFixBackslash, MU, "fix-backslash", BL, yes, ParsePickList, &boolPicks }, - { TidyFixComments, MU, "fix-bad-comments", BL, no, ParsePickList, &boolPicks }, + { TidyFixComments, MU, "fix-bad-comments", IN, TidyAutoState, ParsePickList, &autoBoolPicks }, { TidyFixUri, MU, "fix-uri", BL, yes, ParsePickList, &boolPicks }, { TidyForceOutput, MS, "force-output", BL, no, ParsePickList, &boolPicks }, { TidyGDocClean, MU, "gdoc", BL, no, ParsePickList, &boolPicks }, diff --git a/src/language_en.h b/src/language_en.h index f97bfd4..0e481de 100755 --- a/src/language_en.h +++ b/src/language_en.h @@ -476,7 +476,9 @@ static languageDefinition language_en = { whichPluralForm_en, { "This option specifies if Tidy should replace unexpected hyphens with " "= characters when it comes across adjacent hyphens. " "
" - "The default is no. " + "The default is auto will which will act as no " + "for HTML5 document types, and yes for all other document " + "types. " "
" "HTML has abandonded SGML comment syntax, and allows adjacent hypens " "for all versions of HTML, although XML and XHTML do not. If you plan " diff --git a/src/lexer.c b/src/lexer.c index 6a6775e..aea7619 100755 --- a/src/lexer.c +++ b/src/lexer.c @@ -2613,7 +2613,22 @@ static Node* GetTokenFromStream( TidyDocImpl* doc, GetTokenMode mode ) Bool isempty = no; AttVal *attributes = NULL; Node *node; - Bool fixComments = cfgBool(doc, TidyFixComments); + Bool fixComments; + + switch ( cfgAutoBool(doc, TidyFixComments) ) + { + case TidyYesState: + fixComments = yes; + break; + + case TidyNoState: + fixComments = no; + break; + + default: + fixComments = (TY_(HTMLVersion)(doc) & HT50) == 0; + break; + } /* Lexer->token must be set on return. Nullify it for safety. */ lexer->token = NULL;