mirror of
https://github.com/Steffo99/unisteffo.git
synced 2024-11-23 00:14:21 +00:00
25 lines
515 B
JavaScript
25 lines
515 B
JavaScript
export default function(input) {
|
|
let indent_regex = /^[ \t]+/;
|
|
|
|
let lines = input.split("\n").filter((line) => {
|
|
return line !== "";
|
|
});
|
|
let match = null;
|
|
|
|
for(let i = 0; i < lines.length; i++) {
|
|
match = indent_regex.exec(lines[i]);
|
|
if(match !== null) break;
|
|
}
|
|
|
|
let start;
|
|
if(match === null) {
|
|
start = 0;
|
|
}
|
|
else {
|
|
start = match[0].length;
|
|
}
|
|
|
|
return lines.map((line) => {
|
|
return line.substr(start);
|
|
}).join("\n");
|
|
}
|