Skip to content

Commit

Permalink
HTML: update fix for space after <i></i>, see #390
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Mar 15, 2021
1 parent 1635632 commit d68dbea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions html/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,6 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
rawTagHash = 0
}
}
} else if t.Hash == I {
if next := tb.Peek(1); next.Hash == I && next.TokenType == html.EndTagToken {
omitSpace = false
}
}
} else if t.Hash == Template {
omitSpace = true // EndTagToken
Expand Down Expand Up @@ -503,6 +499,13 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
tb.Shift()
}
}

// keep space after <i></i> for FontAwesome etc.
if t.TokenType == html.StartTagToken && t.Hash == I {
if next := tb.Peek(0); next.Hash == I && next.TokenType == html.EndTagToken {
omitSpace = false
}
}
}
}
}
4 changes: 2 additions & 2 deletions html/html_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ func TestHTML(t *testing.T) {
{`<script><!--<`, `<script><!--<`},

// bugs
{`<i></i> Text`, `<i></i> Text`}, // #390
{`<i> </i> Text`, `<i></i>Text`}, // #390
{`<i class="fas"></i> Text`, `<i class=fas></i> Text`}, // #390
{`<i class="fas"> </i> Text`, `<i class=fas></i>Text`}, // #390
{`<span translate="no">`, `<span translate=no>`}, // #352
{`<input title=""><input lang="">`, `<input title><input lang>`}, // #331
{`<amp-analytics type=adobeanalytics_nativeConfig>`, `<amp-analytics type=adobeanalytics_nativeConfig>`}, // #270
Expand Down

0 comments on commit d68dbea

Please sign in to comment.