Skip to content

Commit

Permalink
HTML: fix whitespace after <math> and <svg>, see #611
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Jan 1, 2024
1 parent 6826bcb commit 91a4f4b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions html/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,15 @@ func (o *Minifier) Minify(m *minify.M, w io.Writer, r io.Reader, _ map[string]st
}
w.Write(t.Data)
}
omitSpace = false
case html.MathToken:
if err := m.MinifyMimetype(mathMimeBytes, w, buffer.NewReader(t.Data), nil); err != nil {
if err != minify.ErrNotExist {
return minify.UpdateErrorPosition(err, z, t.Offset)
}
w.Write(t.Data)
}
omitSpace = false
case html.TextToken:
if t.HasTemplate {
w.Write(t.Data)
Expand Down
2 changes: 2 additions & 0 deletions html/html_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ func TestHTML(t *testing.T) {
{`<source type='video/mp4; codecs="av01.0.05M.08"'>`, `<source type='video/mp4;codecs="av01.0.05M.08"'>`}, // #545
{`<html lang="mn-Cyrl-MN">`, `<html lang=mn-Cyrl-MN>`}, // #579
{`<script src=a></script> <script src=b></script> <span></span>`, `<script src=a></script><script src=b></script><span></span>`}, // #592
{`a <math>b</math> c`, `a <math>b</math> c`}, // #611
{`a <svg>b</svg> c`, `a <svg>b</svg> c`}, // #611
}

m := minify.New()
Expand Down

0 comments on commit 91a4f4b

Please sign in to comment.