Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

includeAutoGeneratedTags not working properly #1045

Open
AndriyGo opened this issue Sep 20, 2019 · 4 comments · May be fixed by #1090
Open

includeAutoGeneratedTags not working properly #1045

AndriyGo opened this issue Sep 20, 2019 · 4 comments · May be fixed by #1090

Comments

@AndriyGo
Copy link

Here is a test case:

<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <div>
      <header> 
      </header>

When I minify it with includeAutoGeneratedTags set to false, I get the following output <!doctype html><div><header></header></div>. As you can see, a closing </div> is added. It is a huge problem when minifying template files.

In case it is relevant, here are all the options which I have (although I did try to change them and they did not influence current behaviour with div):

{
  "caseSensitive": false,
  "collapseBooleanAttributes": true,
  "collapseInlineTagWhitespace": true,
  "collapseWhitespace": true,
  "conservativeCollapse": false,
  "decodeEntities": true,
  "html5": true,
  "includeAutoGeneratedTags": false,
  "keepClosingSlash": false,
  "maxLineLength": 0,
  "minifyCSS": true,
  "minifyJS": true,
  "preserveLineBreaks": false,
  "preventAttributesEscaping": false,
  "processConditionalComments": true,
  "processScripts": [
    "text/html",
"application/ld+json"
  ],
  "removeAttributeQuotes": false,
  "removeComments": true,
  "removeEmptyAttributes": true,
  "removeEmptyElements": false,
  "removeOptionalTags": true,
  "removeRedundantAttributes": true,
  "removeScriptTypeAttributes": true,
  "removeStyleLinkTypeAttributes": true,
  "removeTagWhitespace": false,
  "sortAttributes": true,
  "sortClassName": true,
  "trimCustomFragments": true,
  "useShortDoctype": true
}

I thought that #540 was supposed to add an option to remove such behavior. Is there any other way yo turn off such additions of closing tags?

@onebelarusianguy
Copy link

+1

@DanielRuf
Copy link

@onebelarusianguy you might want to try the latest version.

I can not reproduce it in my fork and also not in the original project:

grafik

grafik

@onebelarusianguy
Copy link

@DanielRuf correct, but if you'd use closed tags </div></body></html> in template file like footer.php, minifier just skip them which lead to invalid markup. But I already solved this issue wrapping closed tags in <!-- htmlmin:ignore --> construction.

@DanielRuf
Copy link

In my opinion the htmlmin:ignore comment to ignore such markup is the correct approach for this case.

There were similar issues about this and that is a valid solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants