Added omit-optional-tags option. Fixes #22.

Thanks towolf.
This commit is contained in:
Michael[tm] Smith 2012-03-24 19:04:46 +09:00
parent f5c273910c
commit 2cd21a6693
7 changed files with 44 additions and 11 deletions

View file

@ -191,8 +191,8 @@ static const CmdOptDesc cmdopt_defs[] = {
"suppress nonessential output", "suppress nonessential output",
"quiet: yes", CmdOptProcDir, "-q" }, "quiet: yes", CmdOptProcDir, "-q" },
{ "-omit", { "-omit",
"omit optional end tags", "omit optional start tags and end tags",
"hide-endtags: yes", CmdOptProcDir }, "omit-optional-tags: yes", CmdOptProcDir },
{ "-xml", { "-xml",
"specify the input is well formed XML", "specify the input is well formed XML",
"input-xml: yes", CmdOptProcDir }, "input-xml: yes", CmdOptProcDir },
@ -1002,7 +1002,7 @@ int main( int argc, char** argv )
tidyOptResetToDefault( tdoc, TidyIndentSpaces ); tidyOptResetToDefault( tdoc, TidyIndentSpaces );
} }
else if ( strcasecmp(arg, "omit") == 0 ) else if ( strcasecmp(arg, "omit") == 0 )
tidyOptSetBool( tdoc, TidyHideEndTags, yes ); tidyOptSetBool( tdoc, TidyOmitOptionalTags, yes );
else if ( strcasecmp(arg, "upper") == 0 ) else if ( strcasecmp(arg, "upper") == 0 )
tidyOptSetBool( tdoc, TidyUpperCaseTags, yes ); tidyOptSetBool( tdoc, TidyUpperCaseTags, yes );

View file

@ -113,7 +113,8 @@ typedef enum
TidyIndentContent, /**< Indent content of appropriate tags */ TidyIndentContent, /**< Indent content of appropriate tags */
/**< "auto" does text/block level content indentation */ /**< "auto" does text/block level content indentation */
TidyCoerceEndTags, /**< Coerce end tags from start tags where probably intended */ 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 */ TidyXmlTags, /**< Treat input as XML */
TidyXmlOut, /**< Create output as XML */ TidyXmlOut, /**< Create output as XML */
TidyXhtmlOut, /**< Output extensible HTML */ TidyXhtmlOut, /**< Output extensible HTML */

View file

@ -8,7 +8,7 @@
<body> <body>
<h1 id="top">Quick Reference</h1> <h1 id="top">Quick Reference</h1>
<h2>HTML Tidy Configuration Options</h2> <h2>HTML Tidy Configuration Options</h2>
<p>Version: <a href="https://github.com/w3c/tidy-html5/tree/ddb5702">https://github.com/w3c/tidy-html5/tree/ddb5702</a></p> <p>Version: <a href="https://github.com/w3c/tidy-html5/tree/4ff3234">https://github.com/w3c/tidy-html5/tree/4ff3234</a></p>
<p> <p>
<a class="h3" href="#MarkupHeader">HTML, XHTML, XML</a> <a class="h3" href="#MarkupHeader">HTML, XHTML, XML</a>
<br /> <br />
@ -322,6 +322,13 @@
<td>Boolean</td> <td>Boolean</td>
<td>no</td> <td>no</td>
</tr> </tr>
<tr>
<td>
<a href="#omit-optional-tags">omit-optional-tags</a>
</td>
<td>Boolean</td>
<td>no</td>
</tr>
<tr> <tr>
<td> <td>
<a href="#output-html">output-html</a> <a href="#output-html">output-html</a>
@ -1149,7 +1156,7 @@
<td align="right" valign="top"></td> <td align="right" valign="top"></td>
</tr> </tr>
<tr> <tr>
<td colspan="2">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. </td> <td colspan="2">This option is an alias for the omit-optional-tags option. </td>
</tr> </tr>
<tr> <tr>
<td>&#160;</td> <td>&#160;</td>
@ -1470,6 +1477,23 @@
<tr> <tr>
<td>&#160;</td> <td>&#160;</td>
</tr> </tr>
<tr>
<td class="tabletitle" valign="top" id="omit-optional-tags">omit-optional-tags</td>
<td class="tabletitlelink" valign="top" align="right">
<a href="#top">Top</a>
</td>
</tr>
<tr>
<td valign="top">Type: <strong>Boolean</strong><br />
Default: <strong>no</strong><br />Example: <strong>y/n, yes/no, t/f, true/false, 1/0</strong></td>
<td align="right" valign="top"></td>
</tr>
<tr>
<td colspan="2">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 &lt;/p&gt;, &lt;/li&gt;, &lt;/dt&gt;, &lt;/dd&gt;, &lt;/option&gt;, &lt;/tr&gt;, &lt;/td&gt;, and &lt;/th&gt;. This option is ignored for XML output. </td>
</tr>
<tr>
<td>&#160;</td>
</tr>
<tr> <tr>
<td class="tabletitle" valign="top" id="output-html">output-html</td> <td class="tabletitle" valign="top" id="output-html">output-html</td>
<td class="tabletitlelink" valign="top" align="right"> <td class="tabletitlelink" valign="top" align="right">

View file

@ -240,6 +240,7 @@ static const TidyOptionImpl option_defs[] =
{ TidyQuiet, MS, "quiet", BL, no, ParseBool, boolPicks }, { TidyQuiet, MS, "quiet", BL, no, ParseBool, boolPicks },
{ TidyIndentContent, PP, "indent", IN, TidyNoState, ParseAutoBool, autoBoolPicks }, { TidyIndentContent, PP, "indent", IN, TidyNoState, ParseAutoBool, autoBoolPicks },
{ TidyCoerceEndTags, MU, "coerce-endtags", BL, yes, ParseBool, boolPicks }, { 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 }, { TidyHideEndTags, MU, "hide-endtags", BL, no, ParseBool, boolPicks },
{ TidyXmlTags, MU, "input-xml", BL, no, ParseBool, boolPicks }, { TidyXmlTags, MU, "input-xml", BL, no, ParseBool, boolPicks },
{ TidyXmlOut, MU, "output-xml", BL, no, ParseBool, boolPicks }, { TidyXmlOut, MU, "output-xml", BL, no, ParseBool, boolPicks },

View file

@ -479,10 +479,16 @@ static const TidyOptionDoc option_docs[] =
"for example, given &lt;span&gt;foo &lt;b&gt;bar&lt;b&gt; baz&lt;/span&gt;, " "for example, given &lt;span&gt;foo &lt;b&gt;bar&lt;b&gt; baz&lt;/span&gt;, "
"Tidy will output &lt;span&gt;foo &lt;b&gt;bar&lt;/b&gt; baz&lt;/span&gt;. " "Tidy will output &lt;span&gt;foo &lt;b&gt;bar&lt;/b&gt; baz&lt;/span&gt;. "
}, },
{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 &lt;/p&gt;, &lt;/li&gt;, &lt;/dt&gt;, &lt;/dd&gt;, "
"&lt;/option&gt;, &lt;/tr&gt;, &lt;/td&gt;, and &lt;/th&gt;. "
"This option is ignored for XML output. "
},
{TidyHideEndTags, {TidyHideEndTags,
"This option specifies if Tidy should omit optional end-tags when " "This option is an alias for the omit-optional-tags option. "
"generating the pretty printed markup. This option is ignored if you are "
"outputting to XML. "
}, },
{TidyIndentCdata, {TidyIndentCdata,
"This option specifies if Tidy should indent &lt;![CDATA[]]&gt; sections. " "This option specifies if Tidy should indent &lt;![CDATA[]]&gt; sections. "

View file

@ -2089,7 +2089,8 @@ void TY_(PPrintTree)( TidyDocImpl* doc, uint mode, uint indent, Node *node )
{ {
Bool indcont = ( cfgAutoBool(doc, TidyIndentContent) != TidyNoState ); Bool indcont = ( cfgAutoBool(doc, TidyIndentContent) != TidyNoState );
Bool indsmart = ( cfgAutoBool(doc, TidyIndentContent) == TidyAutoState ); Bool indsmart = ( cfgAutoBool(doc, TidyIndentContent) == TidyAutoState );
Bool hideend = cfgBool( doc, TidyHideEndTags ); Bool hideend = cfgBool( doc, TidyHideEndTags ) ||
cfgBool( doc, TidyOmitOptionalTags );
Bool classic = cfgBool( doc, TidyVertSpace ); Bool classic = cfgBool( doc, TidyVertSpace );
uint contentIndent = indent; uint contentIndent = indent;

View file

@ -1 +1 @@
static const char TY_(release_date)[] = "https://github.com/w3c/tidy-html5/tree/4ff3234"; static const char TY_(release_date)[] = "https://github.com/w3c/tidy-html5/tree/f5c2739";