From 3ab98e86434857511dc33a68b32d9e8b9c334378 Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Thu, 18 Feb 2016 04:41:16 +0800 Subject: [PATCH] integrate tag omission rules from WhatWG fixes #497 --- dist/htmlminifier.js | 68 +++++++++++++++++++++++++++++++--------- dist/htmlminifier.min.js | 2 +- src/htmlminifier.js | 68 +++++++++++++++++++++++++++++++--------- tests/minifier.js | 60 ++++++++++++++++++++++++++++++----- 4 files changed, 160 insertions(+), 38 deletions(-) diff --git a/dist/htmlminifier.js b/dist/htmlminifier.js index 49061fc..5fedfe0 100644 --- a/dist/htmlminifier.js +++ b/dist/htmlminifier.js @@ -922,17 +922,48 @@ return text.replace(reStartDelimiter[tag], '').replace(reEndDelimiter[tag], ''); } - // Tag omission rules from http://www.w3.org/TR/html5/syntax.html#optional-tags - var optionalStartTags = createMapFromString('html,head,body'); - var optionalEndTags = createMapFromString('html,head,body,li,dt,dd,p,rb,rt,rtc,rp,optgroup,option,colgroup,thead,tbody,tfoot,tr,td,th'); - var headerTags = createMapFromString('meta,link,script,style,template'); + // Tag omission rules from https://html.spec.whatwg.org/multipage/syntax.html#optional-tags + // with the following deviations: + // - retain if followed by