Skip to content

default true CLI options can't be disabled ("include-auto-generated-tags") #860

@bulk88

Description

@bulk88

given file

<html><head><meta name="mobileoptimized" content="0"></head><body>
<a href="#1">&nbsp;1&nbsp;</a> 
<a href="#2">&nbsp;2&nbsp;</a> 
<a href="#3">&nbsp;3&nbsp;</a> 
<a href="#4">&nbsp;4&nbsp;</a> 
<a href="#5">&nbsp;5&nbsp;</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>&nbsp;1&nbsp;</a> <a href=#2>&nbsp;2&nbsp;</a> <a href=#3>&nbsp;3&nbsp;</a> <a href=#4>&nbsp;4&nbsp;</a> <a href=#5>&nbsp;5&nbsp;</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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions