Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function(instance, pluginOptions) {
instance.whitespaceState = new TokenizerState();
instance.whitespaceState.init({}, instance.state.input);
instance.whitespaceState.type = tokenTypes.whitespace;
instance.cstState = {
format: pluginOptions.format || {}
};
instance.extend("skipSpace", function(/*inner*/ /*complete override*/) {
return function skipSpace() {
this.startWhitespace();
loop: while (this.state.pos < this.input.length) {
let ch = this.input.charCodeAt(this.state.pos);
switch (ch) {
case 32: case 160: // ' '
this.whitespaceState.value += String.fromCharCode(ch);
++this.state.pos;
getTokenFromString(input, stateOpts) {
this.input = input;
this.state = new State();
this.state.init(input);
Object.assign(this.state, stateOpts);
this.skipSpace();
if (this.state.comments.length > 0) {
let comment = this.state.comments[0];
this.state.type = comment.type;
this.state.value = comment.value;
} else if (this.state.pos >= this.input.length) {
this.state.type = "Whitespace";
this.state.value = input;
} else {
this.readToken(this.fullCharCodeAtPos());
}
finishToken(type, val) {
this.state.type = type;
this.state.value = val;
if (this.state.pos !== this.input.length) {
if (this.triedTmplToken) {
this.raise(0, "Did not consume entire string '" + this.input + "'");
} else {
this.state = new State();
this.state.init(this.input);
try {
this.readTmplToken();
} catch (e) {
this.raise(0, "Could not consume entire string '" + this.input + "'");
}
}
}
}