From 2cd21a66937b89638e5965c141e1cfe53bfdda81 Mon Sep 17 00:00:00 2001 From: "Michael[tm] Smith" Date: Sat, 24 Mar 2012 19:04:46 +0900 Subject: [PATCH] Added omit-optional-tags option. Fixes #22. Thanks towolf. --- console/tidy.c | 6 +++--- include/tidyenum.h | 3 ++- quickref.html | 28 ++++++++++++++++++++++++++-- src/config.c | 1 + src/localize.c | 12 +++++++++--- src/pprint.c | 3 ++- src/version.h | 2 +- 7 files changed, 44 insertions(+), 11 deletions(-) diff --git a/console/tidy.c b/console/tidy.c index 68a6327..76d6888 100644 --- a/console/tidy.c +++ b/console/tidy.c @@ -191,8 +191,8 @@ static const CmdOptDesc cmdopt_defs[] = { "suppress nonessential output", "quiet: yes", CmdOptProcDir, "-q" }, { "-omit", - "omit optional end tags", - "hide-endtags: yes", CmdOptProcDir }, + "omit optional start tags and end tags", + "omit-optional-tags: yes", CmdOptProcDir }, { "-xml", "specify the input is well formed XML", "input-xml: yes", CmdOptProcDir }, @@ -1002,7 +1002,7 @@ int main( int argc, char** argv ) tidyOptResetToDefault( tdoc, TidyIndentSpaces ); } else if ( strcasecmp(arg, "omit") == 0 ) - tidyOptSetBool( tdoc, TidyHideEndTags, yes ); + tidyOptSetBool( tdoc, TidyOmitOptionalTags, yes ); else if ( strcasecmp(arg, "upper") == 0 ) tidyOptSetBool( tdoc, TidyUpperCaseTags, yes ); diff --git a/include/tidyenum.h b/include/tidyenum.h index 91da43a..d99713b 100644 --- a/include/tidyenum.h +++ b/include/tidyenum.h @@ -113,7 +113,8 @@ typedef enum TidyIndentContent, /**< Indent content of appropriate tags */ /**< "auto" does text/block level content indentation */ TidyCoerceEndTags, /**< Coerce end tags from start tags where probably intended */ - TidyHideEndTags, /**< Suppress optional end tags */ + TidyOmitOptionalTags,/**< Suppress optional start tags and end tags */ + TidyHideEndTags, /**< Legacy name for TidyOmitOptionalTags */ TidyXmlTags, /**< Treat input as XML */ TidyXmlOut, /**< Create output as XML */ TidyXhtmlOut, /**< Output extensible HTML */ diff --git a/quickref.html b/quickref.html index 168ef43..d7199e4 100644 --- a/quickref.html +++ b/quickref.html @@ -8,7 +8,7 @@

Quick Reference

HTML Tidy Configuration Options

-

Version: https://github.com/w3c/tidy-html5/tree/ddb5702

+

Version: https://github.com/w3c/tidy-html5/tree/4ff3234

HTML, XHTML, XML
@@ -322,6 +322,13 @@ Boolean no + + + omit-optional-tags + + Boolean + no + output-html @@ -1149,7 +1156,7 @@ - This option specifies if Tidy should omit optional end-tags when generating the pretty printed markup. This option is ignored if you are outputting to XML. + This option is an alias for the omit-optional-tags option.   @@ -1470,6 +1477,23 @@   + + omit-optional-tags + + Top + + + + Type: Boolean
+ Default: no
Example: y/n, yes/no, t/f, true/false, 1/0 + + + + This option specifies if Tidy should omit optional start tags and end tags when generating output. Setting this option causes all tags for the html, head, and body elements to be omitted from output, as well as such end tags as </p>, </li>, </dt>, </dd>, </option>, </tr>, </td>, and </th>. This option is ignored for XML output. + + +   + output-html diff --git a/src/config.c b/src/config.c index 0f42596..26309d2 100644 --- a/src/config.c +++ b/src/config.c @@ -240,6 +240,7 @@ static const TidyOptionImpl option_defs[] = { TidyQuiet, MS, "quiet", BL, no, ParseBool, boolPicks }, { TidyIndentContent, PP, "indent", IN, TidyNoState, ParseAutoBool, autoBoolPicks }, { TidyCoerceEndTags, MU, "coerce-endtags", BL, yes, ParseBool, boolPicks }, + { TidyOmitOptionalTags, MU, "omit-optional-tags", BL, no, ParseBool, boolPicks }, { TidyHideEndTags, MU, "hide-endtags", BL, no, ParseBool, boolPicks }, { TidyXmlTags, MU, "input-xml", BL, no, ParseBool, boolPicks }, { TidyXmlOut, MU, "output-xml", BL, no, ParseBool, boolPicks }, diff --git a/src/localize.c b/src/localize.c index 99acc86..8791ab9 100644 --- a/src/localize.c +++ b/src/localize.c @@ -479,10 +479,16 @@ static const TidyOptionDoc option_docs[] = "for example, given <span>foo <b>bar<b> baz</span>, " "Tidy will output <span>foo <b>bar</b> baz</span>. " }, + {TidyOmitOptionalTags, + "This option specifies if Tidy should omit optional start tags and end tags " + "when generating output. Setting this option causes all tags for the " + "html, head, and body elements to be omitted from output, as well as such " + "end tags as </p>, </li>, </dt>, </dd>, " + "</option>, </tr>, </td>, and </th>. " + "This option is ignored for XML output. " + }, {TidyHideEndTags, - "This option specifies if Tidy should omit optional end-tags when " - "generating the pretty printed markup. This option is ignored if you are " - "outputting to XML. " + "This option is an alias for the omit-optional-tags option. " }, {TidyIndentCdata, "This option specifies if Tidy should indent <![CDATA[]]> sections. " diff --git a/src/pprint.c b/src/pprint.c index af5417e..375abb8 100644 --- a/src/pprint.c +++ b/src/pprint.c @@ -2089,7 +2089,8 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node ) { Bool indcont = ( cfgAutoBool(doc, TidyIndentContent) != TidyNoState ); Bool indsmart = ( cfgAutoBool(doc, TidyIndentContent) == TidyAutoState ); - Bool hideend = cfgBool( doc, TidyHideEndTags ); + Bool hideend = cfgBool( doc, TidyHideEndTags ) || + cfgBool( doc, TidyOmitOptionalTags ); Bool classic = cfgBool( doc, TidyVertSpace ); uint contentIndent = indent; diff --git a/src/version.h b/src/version.h index 63fd70d..f4bd2c4 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -static const char TY_(release_date)[] = "https://github.com/w3c/tidy-html5/tree/4ff3234"; \ No newline at end of file +static const char TY_(release_date)[] = "https://github.com/w3c/tidy-html5/tree/f5c2739"; \ No newline at end of file