-
Notifications
You must be signed in to change notification settings - Fork 584
Description
given file
<html><head><meta name="mobileoptimized" content="0"></head><body>
<a href="#1"> 1 </a>
<a href="#2"> 2 </a>
<a href="#3"> 3 </a>
<a href="#4"> 4 </a>
<a href="#5"> 5 </a>
<br><br>
<a name="1">1: <a href="#A">A</a><br>
<a name="2">2: <a href="#B">B</a><br>
<a name="3">3: <a href="#C">C</a><br>
<a name="4">4: <a href="#D">D</a><br>
<a name="5">5: <a href="#E">E</a><br>
<br><br>
<a name="A"><a href="s.htm#A1">Page 1</a><br>
<a name="B"><a href="s.htm#A2">Page 2</a><br>
<a name="C"><a href="s.htm#A3">Page 3</a><br>
<a name="D"><a href="s.htm#A4">Page 4</a><br>
<a name="E"><a href="s.htm#A5">Page 5</a><br>
</body></html>
which has target anchors with no contents and no closing tag. No closing tag is on purpose for space optimization, since HTML prohibits an A tag in an A tag and implicitly closes the last one when it encounters an opening A tag. I am using the following line to minify this HTML file.
html-minifier --collapse-boolean-attributes --collapse-whitespace --html5 --remove-attribute-quotes --remove-comments --remove-empty-attributes --remove-optional-tags --remove-redundant-attributes --remove-script-type-attributes --remove-style-link-type-attributes --remove-tag-whitespace --sort-attributes --sort-class-name --trim-custom-fragments --use-short-doctype --minify-js -o testm.htm test.htm
gives
<meta content=0 name=mobileoptimized><a href=#1> 1 </a> <a href=#2> 2 </a> <a href=#3> 3 </a> <a href=#4> 4 </a> <a href=#5> 5 </a><br><br><a name=1>1: <a href=#A>A</a><br><a name=2>2: <a href=#B>B</a><br><a name=3>3: <a href=#C>C</a><br><a name=4>4: <a href=#D>D</a><br><a name=5>5: <a href=#E>E</a><br><br><br><a name=A><a href=s.htm#A1>Page 1</a><br><a name=B><a href=s.htm#A2>Page 2</a><br><a name=C><a href=s.htm#A3>Page 3</a><br><a name=D><a href=s.htm#A4>Page 4</a><br><a name=E><a href=s.htm#A5>Page 5</a><br></a></a></a></a></a></a></a></a></a></a>
with all those extra "</a>"s. Adding "--include-auto-generated-tags" doesn't change the output, since the default for "includeAutoGeneratedTags" is true. "--noinclude-auto-generated-tags" and "--no-include-auto-generated-tags" dont change the output either.
"--include-auto-generated-tags 0" breaks everything
Cannot read 0
ENOENT: no such file or directory, open 'C:\Documents and Settings\Owner\Desktop
\htmpages\0'
If I use the following JSON config
{
"collapseBooleanAttributes": true,
"collapseWhitespace": true,
"html5": true,
"removeAttributeQuotes": true,
"removeComments": true,
"removeEmptyAttributes": true,
"removeEmptyElements": true,
"removeOptionalTags": true,
"removeRedundantAttributes": true,
"removeScriptTypeAttributes": true,
"removeStyleLinkTypeAttributes": true,
"removeTagWhitespace": true,
"sortAttributes": true,
"sortClassName": true,
"trimCustomFragments": true,
"useShortDoctype": true,
"minifyJS": true
}
it produces the extra "</a>"s. If I add "includeAutoGeneratedTags": false to the config file, the extra "</a>"s are gone. So its not possible AFAIK to turn off includeAutoGeneratedTags from the CLI.