Repository navigation
Closed
Description
Closing tag is omitted, but it's incorrect in that case.
$ cat minify.html
<!DOCTYPE html>
<html lang="en">
<head></head>
<body>
<template>
<li>
<div></div>
</li>
<div></div>
</template>
</body>
</html>
$ minify minify.html | newline
<!doctype html><html lang=en><template><li><div></div><div></div></template>
$ minify --version
minify built from source
$ go version -m `which minify`
/Users/nik/.go/bin/minify: go1.25.1
path github.com/tdewolff/minify/v2/cmd/minify
mod github.com/tdewolff/minify/v2 v2.24.8 h1:58/VjsbevI4d5FGV0ZSuBrHMSSkH4MCH0sIz/eKIauE=
dep github.com/djherbis/atime v1.1.0 h1:rgwVbP/5by8BvvjBNrbh64Qz33idKT3pSnMSJsxhi0g=
dep github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
dep github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
dep github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
dep github.com/tdewolff/argp v0.0.0-20250430135133-0f54527d2b1e h1:2jfHhbjBKS2wfyvcz5W2eOkQVKv57DKM1C/QYhTovhs=
dep github.com/tdewolff/parse/v2 v2.8.5 h1:ZmBiA/8Do5Rpk7bDye0jbbDUpXXbCdc3iah4VeUvwYU=
dep golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
dep gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
build -buildmode=exe
build -compiler=gc
build DefaultGODEBUG=containermaxprocs=0,decoratemappings=0,tlssha1=1,updatemaxprocs=0,x509sha256skid=0
build CGO_ENABLED=1
build CGO_CFLAGS=
build CGO_CPPFLAGS=
build CGO_CXXFLAGS=
build CGO_LDFLAGS=
build GOARCH=arm64
build GOOS=darwin
build GOARM64=v8.0
Installed like that go install github.com/tdewolff/minify/v2/cmd/minify@latest
which mentioned here https://github.com/tdewolff/minify/tree/master/cmd/minify#installation
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]Minify removes all children except the first one from the HTML template tag[/-][+]Minify breaks simple html document[/+][-]Minify breaks simple html document[/-][+]Closing </li> tag omitted incorrectly[/+]tdewolff commentedon Feb 17, 2026
Part of the problem is that your HTML is illegal. LI tags may only be contained by UL, OL and MENU tags, which contents must be only LI, TEMPLATE or SCRIPT tags. Wherever you use that template, it must be within those parent tags, which don't permit those DIV tags there.
I'm not sure if the solution is working with invalid HTML or fixing the HTML!
nikandfor commentedon Feb 17, 2026
I think it's allowed to put whatever in template. I'm cloning and inserting this li elements into appropriate ul. And I also have additional node I insert into that li conditionally. Template shouldn't interpret its content.
from here: https://html.spec.whatwg.org/multipage/scripting.html#the-template-element
If I'm wrong, it becomes a choice of the tool being strict spec validator vs being forgiving. Chrome browser parses it with no issues.
Anyways
--html-keep-end-tagsallows to avoid the problem, so it's not urgent at least.tdewolff commentedon Feb 18, 2026
I was understanding that you'd copy the ENTIRE content of the template tag somewhere else, but I understand it is also used to copy a single node inside the template as well. I've added a fix!
HTML: don't remove end tags in <template>, fixes tdewolff#907