Fix buildStats when tags and classes are disabled

Fixes #11202
This commit is contained in:
Bjørn Erik Pedersen 2023-07-03 09:58:33 +02:00
parent 5afc89f2bf
commit ceb486f98c
No known key found for this signature in database
GPG key ID: 330E6E2BD4859D8F
2 changed files with 9 additions and 5 deletions

View file

@ -1232,6 +1232,15 @@ disabletags = true
b = r(` b = r(`
[build.buildStats] [build.buildStats]
enable = true
disabletags = true
disableclasses = true
`)
b.AssertFileContent("hugo_stats.json", "! myclass", "! div", "myid")
b = r(`
[build.buildStats]
enable = false enable = false
`) `)
b.AssertDestinationExists("hugo_stats.json", false) b.AssertDestinationExists("hugo_stats.json", false)

View file

@ -372,11 +372,6 @@ func htmlLexToEndOfComment(w *htmlElementsCollectorWriter) htmlCollectorStateFun
func (w *htmlElementsCollectorWriter) parseHTMLElement(elStr string) (el htmlElement, err error) { func (w *htmlElementsCollectorWriter) parseHTMLElement(elStr string) (el htmlElement, err error) {
conf := w.collector.conf conf := w.collector.conf
if conf.DisableTags && conf.DisableClasses {
// Nothing to do.
return
}
tagName := parseStartTag(elStr) tagName := parseStartTag(elStr)
el.Tag = strings.ToLower(tagName) el.Tag = strings.ToLower(tagName)