1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-28 10:40:52 +02:00

Update cleanup.js

This commit is contained in:
Mike Kamermans
2017-09-18 20:41:13 -07:00
committed by GitHub
parent e31449548a
commit 7e1cefa73f

View File

@@ -11,17 +11,15 @@ module.exports = function cleanUp(latex) {
var indent = false;
var lines = latex.split('\n').filter(line => !!line.trim());
var clean = function(line, idx) {
if(line.trim()) {
if (!indent) {
var matched = line.match(/^(\s+)/);
if (matched) {
indent = matched[0];
}
}
if (indent) {
lines[idx] = line.replace(indent,'').trim();
if (!indent) {
var matched = line.match(/^(\s+)/);
if (matched) {
indent = matched[0];
}
}
if (indent) {
lines[idx] = line.replace(indent,'').trim();
}
}
lines.forEach(clean);
latex = lines.join('\n');