Skip to content

Commit

Permalink
Remove picture and audio from being objectTags; remove first space of…
Browse files Browse the repository at this point in the history
… omitSpace=true
  • Loading branch information
tdewolff committed Apr 13, 2020
1 parent a647bfd commit 8a5c9ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions html/html_test.go
Expand Up @@ -101,6 +101,10 @@ func TestHTML(t *testing.T) {
{`<p class=" name ">`, `<p class=name>`},
{`<p onclick=" javascript:lala ">`, `<p onclick=lala>`},
{`<p url=" http://test ">`, `<p url=http://test>`},
{`a<span> <img> </span>b`, `a<span> <img> </span>b`},
{`a <span> <img> </span>b`, `a <span><img> </span>b`},
{`a<picture> <img> </picture>b`, `a<picture> <img> </picture>b`},
{`a <picture> <img> </picture>b`, `a <picture><img> </picture>b`},

// from HTML Minifier
{`<DIV TITLE="blah">boo</DIV>`, `<div title=blah>boo</div>`},
Expand Down
16 changes: 8 additions & 8 deletions html/table.go
Expand Up @@ -3,12 +3,12 @@ package html
type traits uint16

const (
normalTag traits = 1 << iota
rawTag
nonPhrasingTag
objectTag
omitPTag // omit p end tag if it is followed by this start tag
keepPTag // keep p end tag if it is followed by this end tag
normalTag traits = 1 << iota
rawTag // raw tags need special processing for their content
nonPhrasingTag // non-phrasing elements are unaffected by whitespace, remove spaces around these tags
objectTag // content tags with a few exclusions, keep spaces after these open/close tags
omitPTag // omit p end tag if it is followed by this start tag
keepPTag // keep p end tag if it is followed by this end tag
)

const (
Expand All @@ -25,7 +25,7 @@ var tagMap = map[Hash]traits{
Area: normalTag,
Article: nonPhrasingTag | omitPTag,
Aside: nonPhrasingTag | omitPTag,
Audio: objectTag | keepPTag,
Audio: keepPTag,
B: normalTag,
Base: normalTag,
Bb: normalTag,
Expand Down Expand Up @@ -95,7 +95,7 @@ var tagMap = map[Hash]traits{
Output: nonPhrasingTag,
P: nonPhrasingTag | omitPTag,
Param: normalTag,
Picture: objectTag,
Picture: normalTag,
Pre: nonPhrasingTag | omitPTag,
Progress: objectTag,
Q: objectTag,
Expand Down

0 comments on commit 8a5c9ca

Please sign in to comment.