mirror of
https://github.com/remy/inliner.git
synced 2024-09-11 17:25:30 +03:00
fix: keep whitespaces and newlines in pre and textareas
This commit is contained in:
parent
f4fc886b5e
commit
fae14c92c3
10
lib/index.js
10
lib/index.js
@ -255,12 +255,10 @@ function main() {
|
||||
inliner.removeComments($(':root')[0], $);
|
||||
// collapse the white space
|
||||
if (inliner.options.collapseWhitespace) {
|
||||
// TODO put white space helper back in
|
||||
$('pre').html(function tidyPre(i, html) {
|
||||
return html.replace(/\n/g, '~~nl~~');
|
||||
});
|
||||
$('textarea').val(function tidyTextarea(i, v) {
|
||||
return v.replace(/\n/g, '~~nl~~').replace(/\s/g, '~~s~~');
|
||||
$('pre, textarea').each(function () {
|
||||
$(this).html($(this).html()
|
||||
.replace(/\n/g, '~~nl~~')
|
||||
.replace(/\s/g, '~~s~~'));
|
||||
});
|
||||
|
||||
html = $.html()
|
||||
|
15
test/fixtures/html-whitespaces.result.html
vendored
Normal file
15
test/fixtures/html-whitespaces.result.html
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>html whitespaces</title> </head> <body> <div><code>// projector page window.addEventListener('storage', function (event) { if (event.key === 'currentSlide') { goToSlide(event.newValue); } });</code></div> <pre><code>// projector page
|
||||
|
||||
window.addEventListener('storage', function (event) {
|
||||
|
||||
if (event.key === 'currentSlide') {
|
||||
goToSlide(event.newValue);
|
||||
}
|
||||
});</code></pre> <textarea><code>// projector page
|
||||
|
||||
window.addEventListener('storage', function (event) {
|
||||
|
||||
if (event.key === 'currentSlide') {
|
||||
goToSlide(event.newValue);
|
||||
}
|
||||
});</code></textarea> </body> </html>
|
33
test/fixtures/html-whitespaces.src.html
vendored
Normal file
33
test/fixtures/html-whitespaces.src.html
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>html whitespaces</title>
|
||||
</head>
|
||||
<body>
|
||||
<div><code>// projector page
|
||||
|
||||
window.addEventListener('storage', function (event) {
|
||||
|
||||
if (event.key === 'currentSlide') {
|
||||
goToSlide(event.newValue);
|
||||
}
|
||||
});</code></div>
|
||||
<pre><code>// projector page
|
||||
|
||||
window.addEventListener('storage', function (event) {
|
||||
|
||||
if (event.key === 'currentSlide') {
|
||||
goToSlide(event.newValue);
|
||||
}
|
||||
});</code></pre>
|
||||
<textarea><code>// projector page
|
||||
|
||||
window.addEventListener('storage', function (event) {
|
||||
|
||||
if (event.key === 'currentSlide') {
|
||||
goToSlide(event.newValue);
|
||||
}
|
||||
});</code></textarea>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user