Skip to content

Commit 3a8be24

Browse files
author
SomaticIT
committed
Fix issue with linefeed detection regexp
1 parent 355784f commit 3a8be24

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

tasks/build-html.js

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = function (grunt) {
5151
//#region Private Methods
5252

5353
function getBuildTags(content) {
54-
var lines = content.replace(/\r\n/g, '\n').split(/\n/),
54+
var lines = content.replace(/\r?\n/g, '\n').split(/\n/),
5555
tag = false,
5656
tags = [],
5757
last;
@@ -121,16 +121,16 @@ module.exports = function (grunt) {
121121
}
122122
else {
123123
// if paths are named, just take values
124-
files = _.values(src);
124+
files = _.values(src);
125125
}
126126
}
127127

128128
if (!Array.isArray(files)) {
129129
files = [files];
130-
}
130+
}
131131

132132
return params.processPath(files, params, opt);
133-
}
133+
}
134134
}
135135
function validateBlockAlways(tag) {
136136
return true;
@@ -208,7 +208,7 @@ module.exports = function (grunt) {
208208
if (options.prefix) {
209209
url = URL.resolve(options.prefix.replace(/\\/g, '/'), url);
210210
}
211-
211+
212212
return processHtmlTagTemplate(options, url);
213213
}).join(EOL);
214214
}
@@ -220,10 +220,10 @@ module.exports = function (grunt) {
220220

221221
var
222222
templates = {
223-
'script': '<script <%= attributes %> src="<%= src %>"></script>',
224-
'script-inline': '<script <%= attributes %>><%= src %></script>',
225-
'style': '<link <%= attributes %> href="<%= src %>" />',
226-
'style-inline': '<style <%= attributes %>><%= src %></style>'
223+
'script': '<script <%= attributes %> src="<%= src %>"></script>',
224+
'script-inline': '<script <%= attributes %>><%= src %></script>',
225+
'style': '<link <%= attributes %> href="<%= src %>" />',
226+
'style-inline': '<style <%= attributes %>><%= src %></style>'
227227
},
228228
validators = {
229229
script: validateBlockWithName,
@@ -285,45 +285,45 @@ module.exports = function (grunt) {
285285
var tags = getBuildTags(content),
286286
config = grunt.config();
287287

288-
tags.forEach(function (tag) {
289-
var raw = tag.lines.join(EOL),
290-
result = "",
291-
tagFiles = validators.validate(tag, params);
292-
293-
if (tagFiles) {
294-
var options = _.extend({}, tag, {
295-
data: _.extend({}, config, params.data),
296-
files: tagFiles,
297-
dest: dest,
298-
prefix: params.prefix,
288+
tags.forEach(function (tag) {
289+
var raw = tag.lines.join(EOL),
290+
result = "",
291+
tagFiles = validators.validate(tag, params);
292+
293+
if (tagFiles) {
294+
var options = _.extend({}, tag, {
295+
data: _.extend({}, config, params.data),
296+
files: tagFiles,
297+
dest: dest,
298+
prefix: params.prefix,
299299
relative: params.relative,
300300
params: params
301-
});
301+
});
302302

303-
result = processors.transform(options);
304-
}
303+
result = processors.transform(options);
304+
}
305305
else if (tagFiles === false) {
306306
grunt.log.warn("Unknown tag detected: '" + tag.type + "'");
307307

308308
if (!params.allowUnknownTags) {
309309
grunt.fail.warn("Use 'parseTag' or 'allowUnknownTags' options to avoid this issue");
310310
}
311311
}
312-
else if (tag.optional) {
312+
else if (tag.optional) {
313313
if (params.logOptionals) {
314314
grunt.log.warn("Tag with type: '" + tag.type + "' and name: '" + tag.name + "' is not configured in your Gruntfile.js but is set optional, deleting block !");
315315
}
316-
}
317-
else {
318-
grunt.fail.warn("Tag with type '" + tag.type + "' and name: '" + tag.name + "' is not configured in your Gruntfile.js !");
319-
}
316+
}
317+
else {
318+
grunt.fail.warn("Tag with type '" + tag.type + "' and name: '" + tag.name + "' is not configured in your Gruntfile.js !");
319+
}
320320

321-
content = content.replace(raw, function () { return result });
322-
});
321+
content = content.replace(raw, function () { return result });
322+
});
323323

324-
if (params.beautify) {
325-
content = beautify.html(content, _.isObject(params.beautify) ? params.beautify : {});
326-
}
324+
if (params.beautify) {
325+
content = beautify.html(content, _.isObject(params.beautify) ? params.beautify : {});
326+
}
327327

328328
return content;
329329
}

0 commit comments

Comments
 (0)