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",
"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 );

View File

@ -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 */

View File

@ -8,7 +8,7 @@
<body>
<h1 id="top">Quick Reference</h1>
<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>
<a class="h3" href="#MarkupHeader">HTML, XHTML, XML</a>
<br />
@ -322,6 +322,13 @@
<td>Boolean</td>
<td>no</td>
</tr>
<tr>
<td>
<a href="#omit-optional-tags">omit-optional-tags</a>
</td>
<td>Boolean</td>
<td>no</td>
</tr>
<tr>
<td>
<a href="#output-html">output-html</a>
@ -1149,7 +1156,7 @@
<td align="right" valign="top"></td>
</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>
<td>&#160;</td>
@ -1470,6 +1477,23 @@
<tr>
<td>&#160;</td>
</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>
<td class="tabletitle" valign="top" id="output-html">output-html</td>
<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 },
{ 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 },

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;, "
"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,
"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 &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 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;

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";