Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (currentNode.is('multilineComment') ||
currentNode.is('singlelineComment')) {
positions.push(i);
continue;
}
// If there are any line breaks in a node with spaces, stop and
// split the node into two: one with spaces before line break
// and one with `\n` symbol and everything that goes after.
// Combine the first one with declaration/@-rule's node:
let linebreakIndex = currentNode.content.indexOf('\n');
if (linebreakIndex !== -1) {
var s = currentNode.content.substring(0, linebreakIndex);
if (s === '') break;
var space = gonzales.createNode({type: 'space', content: s});
node.insert(i + 1, space);
positions.push(i + 1);
currentNode.content = currentNode.content
.substring(linebreakIndex);
break;
}
positions.push(i);
}
return positions;
},
ast.traverse(function(node) {
// If found block node stop at the next one for space check
if (!node.is('block') && !node.is('atrulers')) return;
if (node.first() &&
node.first().is('space')) {
node.first().content = value;
} else if (value !== '') {
var space = gonzales.createNode({
type: 'space',
content: value
});
node.insert(0, space);
}
});
},
payload: function (info, i) {
// `node.get(i - 1)` can be either space or comment:
var whitespaceNode = node.get(i - 1);
if (!whitespaceNode) return;
// If it's a comment, insert an empty space node:
if (!whitespaceNode.is('space')) {
whitespaceNode = gonzales.createNode({
type: 'space',
content: ''
});
node.insert(i - 1, whitespaceNode);
}
let content = whitespaceNode.content;
let updatedContent = updateIndent(info, dict, content);
whitespaceNode.content = updatedContent;
}
});
payload: function(info, i) {
// `node.get(i - 1)` can be either space or comment:
var whitespaceNode = node.get(i - 1);
if (!whitespaceNode) return;
// If it's a comment, insert an empty space node:
if (!whitespaceNode.is('space')) {
whitespaceNode = gonzales.createNode({
type: 'space',
content: ''
});
node.insert(i - 1, whitespaceNode);
}
let content = whitespaceNode.content;
let updatedContent = updateIndent(info, dict, content);
whitespaceNode.content = updatedContent;
}
});
if (blockIndent) {
value += new Array(level).join(blockIndent);
}
}
// If found block node stop at the next one for space check
// For the pre-block node, find its last (the deepest) child
var whitespaceNode = getLastWhitespaceNode(node);
// If it's spaces, modify this node
// If it's something different from spaces, add a space node
// to the end
if (whitespaceNode) {
whitespaceNode.content = value;
} else if (value !== '') {
var space = gonzales.createNode({
type: 'space',
content: value
});
node.content.push(space);
}
processBlock(node, level);
});
}
createNode: function(opts) {
return this.extend(gonzales.createNode({
type: 'stylesheet',
syntax: 'scss',
content: [],
start: {line: 1, column: 1},
end: {line: 1, column: 1}
}), opts || {});
},
process(ast) {
var lastChild = ast.last();
if (!lastChild.is('space')) {
lastChild = gonzales.createNode({type: 'space', content: ''});
ast.content.push(lastChild);
}
lastChild.content = lastChild.content.replace(/\n$/, '');
if (this.value) lastChild.content += '\n';
},
process(ast) {
this.newLinesString = this.buildSpacing(ast.syntax);
this.newLinesNode = gonzales.createNode({
type: 'space',
content: this.newLinesString
});
this.processBlock(ast);
},
payload: function (info, i) {
for (var x = node.get(i).length; x--;) {
if (node.get(i).get(x).is('value')) break;
}
let prevNode = node.get(i).get(x - 1);
if (!prevNode.is('space')) {
var space = gonzales.createNode({
type: 'space',
content: ''
});
node.get(i).insert(x, space);
++x;
}
let content = node.get(i).get(x - 1).content;
let updatedIndent = updateIndent(info, dict, content);
node.get(i).get(x - 1).content = updatedIndent;
}
});
return;
}
if (metOperator && atRuleNode.is('space') && !cleaned) {
return;
}
if (!wrongVar) {
cleaned = true;
atRuleNode.type = 'string';
atRuleNode.content = '';
}
});
if (!wrongVar) {
var newVal = gonzales.createNode({ type: 'string', content: variable.value, syntax: 'less' });
node.content.push(newVal);
}
});