From 97c9bfb143de98ca44c3acbed15aac4a9ebec0ef Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Sat, 26 Mar 2016 18:00:27 +0800 Subject: [PATCH] eliminate removeCommentsFromCDATA migrate non-overlapping functionalities to minifyJS and minifyCSS fixes #579 --- README.md | 1 - assets/master.js | 1 - cli.js | 1 - dist/htmlminifier.js | 26 +++------ dist/htmlminifier.min.js | 2 +- index.html | 4 -- sample-cli-config-file.conf | 1 - src/htmlminifier.js | 26 +++------ tests/minifier.js | 102 +++++++++++++++++++++++++++--------- 9 files changed, 93 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 985fa45..ecfc1f3 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,6 @@ How does HTMLMinifier compare to other solutions — [HTML Minifier from Will Pe | Option | Description | Default | |--------------------------------|-----------------|---------| | `removeComments` | [Strip HTML comments](http://perfectionkills.com/experimenting-with-html-minifier/#remove_comments) | `false` | -| `removeCommentsFromCDATA` | [Strip HTML comments from scripts and styles](http://perfectionkills.com/experimenting-with-html-minifier/#remove_comments_from_scripts_and_styles) | `false` | | `removeCDATASectionsFromCDATA` | [Remove CDATA sections from script and style elements](http://perfectionkills.com/experimenting-with-html-minifier/#remove_cdata_sections) | `false` | | `collapseWhitespace` | [Collapse white space that contributes to text nodes in a document tree.](http://perfectionkills.com/experimenting-with-html-minifier/#collapse_whitespace) | `false` | | `conservativeCollapse` | Always collapse to 1 space (never remove it entirely). Must be used in conjunction with `collapseWhitespace=true` | `false` | diff --git a/assets/master.js b/assets/master.js index ec4a85d..7a51f03 100644 --- a/assets/master.js +++ b/assets/master.js @@ -15,7 +15,6 @@ function getOptions() { return { removeComments: byId('remove-comments').checked, - removeCommentsFromCDATA: byId('remove-comments-from-cdata').checked, removeCDATASectionsFromCDATA: byId('remove-cdata-sections-from-cdata').checked, collapseWhitespace: byId('collapse-whitespace').checked, conservativeCollapse: byId('conservative-collapse').checked, diff --git a/cli.js b/cli.js index 121c814..b5d163b 100755 --- a/cli.js +++ b/cli.js @@ -81,7 +81,6 @@ var mainOptions = { removeAttributeQuotes: [[false, 'Remove quotes around attributes when possible.']], removeCDATASectionsFromCDATA: [[false, 'Remove CDATA sections from script and style elements']], removeComments: [[false, 'Strip HTML comments']], - removeCommentsFromCDATA: [[false, 'Strip HTML comments from scripts and styles']], removeEmptyAttributes: [[false, 'Remove all attributes with whitespace-only values']], removeEmptyElements: [[false, 'Remove all elements with empty contents']], removeOptionalTags: [[false, 'Remove unrequired tags']], diff --git a/dist/htmlminifier.js b/dist/htmlminifier.js index f6f697d..15ff473 100644 --- a/dist/htmlminifier.js +++ b/dist/htmlminifier.js @@ -32121,19 +32121,6 @@ function processScript(text, options, currentAttrs) { return text; } -var reStartDelimiter = { - // account for js + html comments (e.g.: //\s*$/, - style: /\s*-->\s*$/ -}; -function removeComments(text, tag) { - return text.replace(reStartDelimiter[tag], '').replace(reEndDelimiter[tag], ''); -} - // Tag omission rules from https://html.spec.whatwg.org/multipage/syntax.html#optional-tags // with the following deviations: // - retain if followed by