Comments (2)
Hi, I have implemented some easy syntax-tag-omission tasks ...
// https://html.spec.whatwg.org/multipage/syntax.html#syntax-tag-omission
// Implemented:
//
// A <p> element's end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, menu, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.
// An <li> element's end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.
// A <td> element's end tag may be omitted if the td element is immediately followed by a td or th element, or if there is no more content in the parent element.
// An <option> element's end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
// A <tr> element's end tag may be omitted if the tr element is immediately followed by another tr element, or if there is no more content in the parent element.
// A <th> element's end tag may be omitted if the th element is immediately followed by a td or th element, or if there is no more content in the parent element.
// A <dt> element's end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
// A <dd> element's end tag may be omitted if the dd element is immediately followed by another dd element or a dt element, or if there is no more content in the parent element.
// An <rp> element's end tag may be omitted if the rp element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
// TODO:
//
// <html> may be omitted if first thing inside is not comment
// <head> may be omitted if first thing inside is an element
// <body> may be omitted if first thing inside is not space, comment, <meta>, <link>, <script>, <style> or <template>
// <colgroup> may be omitted if first thing inside is <col>
// <tbody> may be omitted if first thing inside is <tr>
// An <optgroup> element's end tag may be omitted if the optgroup element is immediately followed by another optgroup element, or if there is no more content in the parent element.
// A <colgroup> element's start tag may be omitted if the first thing inside the colgroup element is a col element, and if the element is not immediately preceded by another colgroup element whose end tag has been omitted. (It can't be omitted if the element is empty.)
// A <colgroup> element's end tag may be omitted if the colgroup element is not immediately followed by ASCII whitespace or a comment.
// A <caption> element's end tag may be omitted if the caption element is not immediately followed by ASCII whitespace or a comment.
// A <thead> element's end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
// A <tbody> element's start tag may be omitted if the first thing inside the tbody element is a tr element, and if the element is not immediately preceded by a tbody, thead, or tfoot element whose end tag has been omitted. (It can't be omitted if the element is empty.)
// A <tbody> element's end tag may be omitted if the tbody element is immediately followed by a tbody or tfoot element, or if there is no more content in the parent element.
// A <tfoot> element's end tag may be omitted if there is no more content in the parent element.
//
// <-- However, a start tag must never be omitted if it has any attributes.
from htmlmin.
Thanks @voku and thanks for the 🏷 2.0.0.
from htmlmin.
Related Issues (20)
- HtmlMin cut html at the end of page HOT 12
- Incorrect processing before and after<nocompress> tag HOT 1
- <p> paragraphs break when compressing, closing tag missing HOT 7
- Whitespace/ommited tags fidelity issue + headless browser testing proposal
- Remove data attributes in tag
- Remove new lines in script type=application/ld+json
- More issues with <code> and <p> HOT 1
- Minify inline Javascript
- PRCE error handling HOT 5
- how to pass html & from where HOT 1
- Dependency Dashboard
- Escaping issues with Mustache.js templates HOT 2
- `doMakeSameDomainsLinksRelative` somewhat counter-intuitive
- Broken minification (`ParseError`)
- Unexpected whitespace removal before anchor tag
- Broken script template tags HOT 2
- Doesn't work in php 8 or greater due to namespaces not being Capitalized
- `sizes` and `srcset` value are not trim...
- Uncaught TypeError with PHP 8.3 and `id` attribute HOT 4
- removing end head tag </head> from file...
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from htmlmin.