mirror of
https://github.com/remy/inliner.git
synced 2024-08-16 20:00:35 +03:00
feat: added preserveComments option
This commit is contained in:
parent
d53c651921
commit
a41ab78a95
@ -15,6 +15,7 @@ function options(args) {
|
||||
'skip-absolute-urls',
|
||||
'videos',
|
||||
'inlinemin',
|
||||
'preserve-comments',
|
||||
],
|
||||
string: [ // options
|
||||
'encoding',
|
||||
@ -32,6 +33,7 @@ function options(args) {
|
||||
o: 'videos',
|
||||
m: 'inlinemin',
|
||||
H: 'header',
|
||||
c: 'preserve-comments',
|
||||
},
|
||||
});
|
||||
|
||||
@ -41,6 +43,10 @@ function options(args) {
|
||||
argv.compressJS = false;
|
||||
argv.collapseWhitespace = false;
|
||||
}
|
||||
if (argv['preserve-comments']) {
|
||||
argv.preserveComments = true;
|
||||
}
|
||||
|
||||
if (argv['skip-absolute-urls']) {
|
||||
argv.skipAbsoluteUrls = true;
|
||||
}
|
||||
|
@ -6,5 +6,6 @@ module.exports = function () {
|
||||
collapseWhitespace: true,
|
||||
nosvg: false, // by default, DO compress SVG with SVGO
|
||||
skipAbsoluteUrls: false,
|
||||
preserveComments: false,
|
||||
};
|
||||
};
|
||||
|
@ -304,7 +304,12 @@ function main() {
|
||||
|
||||
return Promise.all(promises).then(function then() {
|
||||
var html = '';
|
||||
inliner.removeComments($(':root')[0], $);
|
||||
|
||||
// remove comments
|
||||
if (!inliner.options.preserveComments) {
|
||||
inliner.removeComments($(':root')[0], $);
|
||||
}
|
||||
|
||||
// collapse the white space
|
||||
if (inliner.options.collapseWhitespace) {
|
||||
$('pre, textarea').each(function () {
|
||||
|
3
test/fixtures/dont-preserve-comments.opts.json
vendored
Normal file
3
test/fixtures/dont-preserve-comments.opts.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"preserveComments": false
|
||||
}
|
1
test/fixtures/dont-preserve-comments.result.html
vendored
Normal file
1
test/fixtures/dont-preserve-comments.result.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>inline script</title> </head> <body> </body> </html>
|
10
test/fixtures/dont-preserve-comments.src.html
vendored
Normal file
10
test/fixtures/dont-preserve-comments.src.html
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>inline script</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- hello -->
|
||||
</body>
|
||||
</html>
|
3
test/fixtures/preserve-comments.opts.json
vendored
Normal file
3
test/fixtures/preserve-comments.opts.json
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"preserveComments": true
|
||||
}
|
1
test/fixtures/preserve-comments.result.html
vendored
Normal file
1
test/fixtures/preserve-comments.result.html
vendored
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>inline script</title> </head> <body> <!-- hello --> </body> </html>
|
10
test/fixtures/preserve-comments.src.html
vendored
Normal file
10
test/fixtures/preserve-comments.src.html
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>inline script</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- hello -->
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user