Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle tags with phrasing content model #541

Merged
merged 2 commits into from
Mar 9, 2016
Merged

handle tags with phrasing content model #541

merged 2 commits into from
Mar 9, 2016

Conversation

alexlamsl
Copy link
Collaborator

HTML5 have strict definitions for content model, so things like <p> cannot have <div> inside for instance.

Auto-close such tags on the boundary of non-phrasing content.

@alexlamsl
Copy link
Collaborator Author

Browsing around HTML 4.01 doesn't seem to have the same restrictions, so confining this logic to html5 mode.

@alexlamsl
Copy link
Collaborator Author

Did a grep on https://html.spec.whatwg.org/ and populated the list of phrasing-content-only tags.

@alexlamsl alexlamsl mentioned this pull request Mar 8, 2016
kangax added a commit that referenced this pull request Mar 9, 2016
handle tags with phrasing content model
@kangax kangax merged commit 7526013 into kangax:gh-pages Mar 9, 2016
@jshcrowthe
Copy link
Contributor

Great work with the spec compliance here! I am using html-minifier (via gulp) for a while now and it has been great. However, in an application using web components, this addition broke me.

Web Components have the unique nature that they can be put in any of the available content categories. In order for this to work with those using web components, tags that are not, by default, part of the HTML spec (and therefore recognized as phrasing, flow, or another type) should be ignored.

I added the following test to https://github.com/kangax/html-minifier/blob/gh-pages/tests/minifier.js#L1191 and it failed:

  test('phrasing content with Web Components', function() {
    input = '<span><phrasing-element></phrasing-element></span>';
    output = '<span><phrasing-element></phrasing-element></span>';
    equal(minify(input, { html5: true }), output);
  });

@devinus
Copy link

devinus commented Mar 17, 2016

How can I turn this off?

@devinus
Copy link

devinus commented Mar 17, 2016

This is closing the tag even when there's a tag later on closing it, which is against the original intent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants