Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80635 views
1
/**
2
* @providesModule unindent
3
*/
4
5
// Remove the indentation introduced by JSX
6
function unindent(code) {
7
var lines = code.split('\n');
8
if (lines[0] === '') {
9
lines.shift();
10
}
11
if (lines.length <= 1) {
12
return code;
13
}
14
15
var indent = lines[0].match(/^\s*/)[0];
16
for (var i = 0; i < lines.length; ++i) {
17
lines[i] = lines[i].replace(new RegExp('^' + indent), '');
18
}
19
return lines.join('\n');
20
}
21
22
module.exports = unindent;
23
24