From d5d58a69835741dc63a4d4d4bf03c233f5ba13ff Mon Sep 17 00:00:00 2001 From: Joshua Sullivan Date: Mon, 12 Feb 2018 08:07:54 -0800 Subject: [PATCH 1/7] Ignore VSCode files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 353261164..e09104305 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store .idea +.vscode testing node_modules lib-cov From 591583f64afdc47bf00f92eab9fd147f393a6068 Mon Sep 17 00:00:00 2001 From: Joshua Sullivan Date: Mon, 12 Feb 2018 08:11:24 -0800 Subject: [PATCH 2/7] Use `loc` on lexer tokens to store source location information --- packages/pug-lexer/index.js | 538 +++++++++++++++++++++++------------- 1 file changed, 340 insertions(+), 198 deletions(-) diff --git a/packages/pug-lexer/index.js b/packages/pug-lexer/index.js index c4f3db5c3..f6b143d00 100644 --- a/packages/pug-lexer/index.js +++ b/packages/pug-lexer/index.js @@ -41,6 +41,7 @@ function Lexer(str, options) { this.indentRe = null; // If #{}, !{} or #[] syntax is allowed when adding text this.interpolationAllowed = true; + this.whitespaceRe = /[ \n\t]/; this.tokens = []; this.ended = false; @@ -106,12 +107,37 @@ Lexer.prototype = { */ tok: function(type, val){ - var res = {type: type, line: this.lineno, col: this.colno}; + var res = { + type: type, + loc: { + start: { + line: this.lineno, + column: this.colno + }, + filename: this.filename + } + }; if (val !== undefined) res.val = val; return res; }, + + /** + * Set the token's `loc.end` value. + * + * @param {Object} tok + * @returns {Object} + * @api private + */ + + tokEnd: function(tok){ + tok.loc.end = { + line: this.lineno, + column: this.colno + }; + return tok; + }, /** * Increment `this.lineno` and reset `this.colno`. @@ -275,9 +301,9 @@ Lexer.prototype = { this.error('NO_END_BRACKET', 'End of line was reached with no closing bracket for interpolation.'); } for (var i = 0; this.indentStack[i]; i++) { - this.tokens.push(this.tok('outdent')); + this.tokens.push(this.tokEnd(this.tok('outdent'))); } - this.tokens.push(this.tok('eos')); + this.tokens.push(this.tokEnd(this.tok('eos'))); this.ended = true; return true; }, @@ -308,6 +334,7 @@ Lexer.prototype = { this.interpolationAllowed = tok.buffer; this.tokens.push(tok); this.incrementColumn(captures[0].length); + this.tokEnd(tok); this.callLexerFunction('pipelessText'); return true; } @@ -330,6 +357,7 @@ Lexer.prototype = { var lines = splitted.length - 1; this.incrementLine(lines); this.incrementColumn(splitted[lines].length + 1); // + 1 → '}' + this.tokEnd(tok); return true; } }, @@ -347,6 +375,7 @@ Lexer.prototype = { tok = this.tok('tag', name); this.tokens.push(tok); this.incrementColumn(len); + this.tokEnd(tok); return true; } }, @@ -361,6 +390,7 @@ Lexer.prototype = { if (tok) { this.tokens.push(tok); this.incrementColumn(tok.val.length); + this.tokEnd(tok); this.callLexerFunction('attrs'); if (!inInclude) { this.interpolationAllowed = false; @@ -377,7 +407,7 @@ Lexer.prototype = { doctype: function() { var node = this.scanEndOfLine(/^doctype *([^\n]*)/, 'doctype'); if (node) { - this.tokens.push(node); + this.tokens.push(this.tokEnd(node)); return true; } }, @@ -391,6 +421,7 @@ Lexer.prototype = { if (tok) { this.tokens.push(tok); this.incrementColumn(tok.val.length); + this.tokEnd(tok); return true; } if (/^#/.test(this.input)) { @@ -407,6 +438,7 @@ Lexer.prototype = { if (tok) { this.tokens.push(tok); this.incrementColumn(tok.val.length); + this.tokEnd(tok); return true; } if (/^\.[_a-z0-9\-]+/i.test(this.input)) { @@ -428,8 +460,10 @@ Lexer.prototype = { } }, addText: function (type, value, prefix, escaped) { + var tok; if (value + prefix === '') return; prefix = prefix || ''; + escaped = escaped || 0; var indexOfEnd = this.interpolated ? value.indexOf(']') : -1; var indexOfStart = this.interpolationAllowed ? value.indexOf('#[') : -1; var indexOfEscaped = this.interpolationAllowed ? value.indexOf('\\#[') : -1; @@ -442,14 +476,15 @@ Lexer.prototype = { if (indexOfEscaped !== Infinity && indexOfEscaped < indexOfEnd && indexOfEscaped < indexOfStart && indexOfEscaped < indexOfStringInterp) { prefix = prefix + value.substring(0, indexOfEscaped) + '#['; - return this.addText(type, value.substring(indexOfEscaped + 3), prefix, true); + return this.addText(type, value.substring(indexOfEscaped + 3), prefix, escaped + 1); } if (indexOfStart !== Infinity && indexOfStart < indexOfEnd && indexOfStart < indexOfEscaped && indexOfStart < indexOfStringInterp) { - this.tokens.push(this.tok(type, prefix + value.substring(0, indexOfStart))); - this.incrementColumn(prefix.length + indexOfStart); - if (escaped) this.incrementColumn(1); - this.tokens.push(this.tok('start-pug-interpolation')); + tok = this.tok(type, prefix + value.substring(0, indexOfStart)); + this.incrementColumn(prefix.length + indexOfStart + escaped); + this.tokens.push(this.tokEnd(tok)); + tok = this.tok('start-pug-interpolation'); this.incrementColumn(2); + this.tokens.push(this.tokEnd(tok)); var child = new this.constructor(value.substr(indexOfStart + 2), { filename: this.filename, interpolated: true, @@ -468,8 +503,9 @@ Lexer.prototype = { } this.colno = child.colno; this.tokens = this.tokens.concat(interpolated); - this.tokens.push(this.tok('end-pug-interpolation')); + tok = this.tok('end-pug-interpolation'); this.incrementColumn(1); + this.tokens.push(this.tokEnd(tok)); this.addText(type, child.input); return; } @@ -484,18 +520,19 @@ Lexer.prototype = { if (indexOfStringInterp !== Infinity) { if (matchOfStringInterp[1]) { prefix = prefix + value.substring(0, indexOfStringInterp) + '#{'; - return this.addText(type, value.substring(indexOfStringInterp + 3), prefix); + return this.addText(type, value.substring(indexOfStringInterp + 3), prefix, escaped + 1); } var before = value.substr(0, indexOfStringInterp); if (prefix || before) { before = prefix + before; - this.tokens.push(this.tok(type, before)); - this.incrementColumn(before.length); + tok = this.tok(type, before); + this.incrementColumn(before.length + escaped); + this.tokens.push(this.tokEnd(tok)); } var rest = matchOfStringInterp[3]; var range; - var tok = this.tok('interpolated-code'); + tok = this.tok('interpolated-code'); this.incrementColumn(2); try { range = characterParser.parseUntil(rest, '}'); @@ -515,21 +552,23 @@ Lexer.prototype = { tok.buffer = true; tok.val = range.src; this.assertExpression(range.src); - this.tokens.push(tok); if (range.end + 1 < rest.length) { rest = rest.substr(range.end + 1); this.incrementColumn(range.end + 1); + this.tokens.push(this.tokEnd(tok)); this.addText(type, rest); } else { this.incrementColumn(rest.length); + this.tokens.push(this.tokEnd(tok)); } return; } value = prefix + value; - this.tokens.push(this.tok(type, value)); - this.incrementColumn(value.length); + tok = this.tok(type, value); + this.incrementColumn(value.length + escaped); + this.tokens.push(this.tokEnd(tok)); }, text: function() { @@ -557,7 +596,7 @@ Lexer.prototype = { dot: function() { var tok; if (tok = this.scanEndOfLine(/^\./, 'dot')) { - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); this.callLexerFunction('pipelessText'); return true; } @@ -570,7 +609,7 @@ Lexer.prototype = { "extends": function() { var tok = this.scan(/^extends?(?= |$|\n)/, 'extends'); if (tok) { - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); if (!this.callLexerFunction('path')) { this.error('NO_EXTENDS_PATH', 'missing path for extends'); } @@ -595,10 +634,14 @@ Lexer.prototype = { name = name.split('//')[0].trim(); } if (!name) return; - this.consume(captures[0].length - comment.length); var tok = this.tok('block', name); + var len = captures[0].length - comment.length; + while(this.whitespaceRe.test(this.input.charAt(len - 1))) len--; + this.incrementColumn(len); tok.mode = 'prepend'; - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); + this.consume(captures[0].length - comment.length); + this.incrementColumn(captures[0].length - comment.length - len); return true; } }, @@ -617,10 +660,14 @@ Lexer.prototype = { name = name.split('//')[0].trim(); } if (!name) return; - this.consume(captures[0].length - comment.length); var tok = this.tok('block', name); + var len = captures[0].length - comment.length; + while(this.whitespaceRe.test(this.input.charAt(len - 1))) len--; + this.incrementColumn(len); tok.mode = 'append'; - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); + this.consume(captures[0].length - comment.length); + this.incrementColumn(captures[0].length - comment.length - len); return true; } }, @@ -639,10 +686,14 @@ Lexer.prototype = { name = name.split('//')[0].trim(); } if (!name) return; - this.consume(captures[0].length - comment.length); var tok = this.tok('block', name); + var len = captures[0].length - comment.length; + while(this.whitespaceRe.test(this.input.charAt(len - 1))) len--; + this.incrementColumn(len); tok.mode = 'replace'; - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); + this.consume(captures[0].length - comment.length); + this.incrementColumn(captures[0].length - comment.length - len); return true; } }, @@ -654,7 +705,7 @@ Lexer.prototype = { mixinBlock: function() { var tok; if (tok = this.scanEndOfLine(/^block/, 'mixin-block')) { - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); return true; } }, @@ -666,7 +717,7 @@ Lexer.prototype = { 'yield': function() { var tok = this.scanEndOfLine(/^yield/, 'yield'); if (tok) { - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); return true; } }, @@ -678,7 +729,7 @@ Lexer.prototype = { include: function() { var tok = this.scan(/^include(?=:| |$|\n)/, 'include'); if (tok) { - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); while (this.callLexerFunction('filter', { inInclude: true })); if (!this.callLexerFunction('path')) { if (/^[^ \n]+/.test(this.input)) { @@ -703,7 +754,7 @@ Lexer.prototype = { path: function() { var tok = this.scanEndOfLine(/^ ([^\n]+)/, 'path'); if (tok && (tok.val = tok.val.trim())) { - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); return true; } }, @@ -718,7 +769,7 @@ Lexer.prototype = { this.incrementColumn(-tok.val.length); this.assertExpression(tok.val); this.incrementColumn(tok.val.length); - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); return true; } if (this.scan(/^case\b/)) { @@ -747,7 +798,7 @@ Lexer.prototype = { this.incrementColumn(-tok.val.length); this.assertExpression(tok.val); this.incrementColumn(tok.val.length); - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); return true; } if (this.scan(/^when\b/)) { @@ -762,7 +813,7 @@ Lexer.prototype = { "default": function() { var tok = this.scanEndOfLine(/^default/, 'default'); if (tok) { - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); return true; } if (this.scan(/^default\b/)) { @@ -813,7 +864,7 @@ Lexer.prototype = { } } } - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); return true; } }, @@ -828,7 +879,8 @@ Lexer.prototype = { this.consume(captures[0].length); var tok = this.tok('mixin', captures[1]); tok.args = captures[2] || null; - this.tokens.push(tok); + this.incrementColumn(captures[0].length); + this.tokens.push(this.tokEnd(tok)); return true; } }, @@ -866,7 +918,8 @@ Lexer.prototype = { } break; } - this.tokens.push(tok); + this.incrementColumn(js.length); + this.tokens.push(this.tokEnd(tok)); return true; } }, @@ -876,11 +929,13 @@ Lexer.prototype = { */ "while": function() { - var captures; + var captures, tok; if (captures = /^while +([^\n]+)/.exec(this.input)) { this.consume(captures[0].length); - this.assertExpression(captures[1]) - this.tokens.push(this.tok('while', captures[1])); + this.assertExpression(captures[1]); + tok = this.tok('while', captures[1]); + this.incrementColumn(captures[0].length); + this.tokens.push(this.tokEnd(tok)); return true; } if (this.scan(/^while\b/)) { @@ -902,7 +957,7 @@ Lexer.prototype = { this.assertExpression(captures[3]) tok.code = captures[3]; this.incrementColumn(captures[3].length); - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); return true; } if (this.scan(/^(?:each|for)\b/)) { @@ -980,6 +1035,7 @@ Lexer.prototype = { // --- code // ^ after colno this.incrementColumn(code.length); + this.tokEnd(tok); return true; } }, @@ -990,172 +1046,244 @@ Lexer.prototype = { blockCode: function() { var tok if (tok = this.scanEndOfLine(/^-/, 'blockcode')) { - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); this.interpolationAllowed = false; this.callLexerFunction('pipelessText'); return true; } }, - + /** - * Attributes. + * Attribute Name. */ - - attrs: function() { - if ('(' == this.input.charAt(0)) { - var startingLine = this.lineno; - this.tokens.push(this.tok('start-attributes')); - var index = this.bracketExpression().end - , str = this.input.substr(1, index-1); - + + attributeName: function(str){ + var quote = ''; + var quoteRe = /['"]/; + var key = ''; + var i; + + characterParser.defaultState(); + + // consume all whitespace before the key + for(i = 0; i < str.length; i++){ + if(!this.whitespaceRe.test(str[i])) break; + if(str[i] === '\n'){ + this.incrementLine(1); + } else { + this.incrementColumn(1); + } + } + + if(i === str.length){ + return ''; + } + + var tok = this.tok('attribute'); + + // quote? + if(quoteRe.test(str[i])){ + quote = str[i]; this.incrementColumn(1); - this.assertNestingCorrect(str); - - var quote = ''; - var self = this; - - this.consume(index + 1); - - var whitespaceRe = /[ \n\t]/; - var quoteRe = /['"]/; - - var escapedAttr = false - var key = ''; - var val = ''; - var state = characterParser.defaultState(); - var lineno = startingLine; - var colnoBeginAttr = this.colno; - var colnoBeginVal; - var loc = 'key'; - var isEndOfAttribute = function (i) { - // if the key is not started, then the attribute cannot be ended - if (key.trim() === '') { - colnoBeginAttr = this.colno; - return false; + i++; + } + + // start looping through the key + for (; i < str.length; i++) { + + if(quote){ + if (str[i] === quote) { + this.incrementColumn(1); + i++; + break; } - // if there's nothing more then the attribute must be ended - if (i === str.length) return true; - - if (loc === 'key') { - if (whitespaceRe.test(str[i])) { - // find the first non-whitespace character - for (var x = i; x < str.length; x++) { - if (!whitespaceRe.test(str[x])) { - // starts a `value` - if (str[x] === '=' || str[x] === '!') return false; - // will be handled when x === i - else if (str[x] === ',') return false; - // attribute ended - else return true; + } else { + if(this.whitespaceRe.test(str[i]) || str[i] === '!' || str[i] === '=' || str[i] === ',') { + break; + } + } + + key += str[i]; + + if (str[i] === '\n') { + this.incrementLine(1); + } else { + this.incrementColumn(1); + } + } + + tok.name = key; + tok.mustEscape = true; + + str = this.attributeValue(tok, str.substr(i)); + + tok.val = tok.val === '' ? true : tok.val; + + this.tokens.push(this.tokEnd(tok)); + + for(i = 0; i < str.length; i++){ + if(!this.whitespaceRe.test(str[i])) { + break; + } + if(str[i] === '\n'){ + this.incrementLine(1); + } else { + this.incrementColumn(1); + } + } + + if(str[i] === ','){ + this.incrementColumn(1); + i++; + } + + return str.substr(i); + }, + + /** + * Attribute Value. + */ + + attributeValue: function(tok, str){ + var quoteRe = /['"]/; + var val = tok.val = ''; + var done, i, x; + var escapeAttr = true; + var state = characterParser.defaultState(); + var col = this.colno; + var line = this.lineno; + + characterParser.defaultState(); + + // consume all whitespace before the equals sign + for(i = 0; i < str.length; i++){ + if(!this.whitespaceRe.test(str[i])) break; + if(str[i] === '\n'){ + line++; + col = 1; + } else { + col++; + } + } + + if(i === str.length){ + return str; + } + + if(str[i] === '!'){ + escapeAttr = false; + col++; + i++; + if (str[i] !== '=') this.error('INVALID_KEY_CHARACTER', 'Unexpected character ' + str[i] + ' expected `=`'); + } + + if(str[i] !== '='){ + // check for anti-pattern `div("foo"bar)` + if (i === 0 && str && !this.whitespaceRe.test(str[0]) && str[0] !== ','){ + this.error('INVALID_KEY_CHARACTER', 'Unexpected character ' + str[0] + ' expected `=`'); + } else { + return str; + } + } + + this.lineno = line; + this.colno = col + 1; + i++; + + // consume all whitespace before the value + for(; i < str.length; i++){ + if(!this.whitespaceRe.test(str[i])) break; + if(str[i] === '\n'){ + this.incrementLine(1); + } else { + this.incrementColumn(1); + } + } + + line = this.lineno; + col = this.colno; + + // start looping through the value + for (; i < str.length; i++) { + // if the character is in a string or in parentheses/brackets/braces + if (!(state.isNesting() || state.isString())){ + + if (this.whitespaceRe.test(str[i])) { + done = false; + + // find the first non-whitespace character + for (x = i; x < str.length; x++) { + if (!this.whitespaceRe.test(str[x])) { + // if it is a JavaScript punctuator, then assume that it is + // a part of the value + if((!characterParser.isPunctuator(str[x]) || quoteRe.test(str[x]) || str[x] === ':') && this.assertExpression(val, true)){ + done = true; } + break; } } - // if there's no whitespace and the character is not ',', the - // attribute did not end. - return str[i] === ','; - } else if (loc === 'value') { - // if the character is in a string or in parentheses/brackets/braces - if (state.isNesting() || state.isString()) return false; - - // if the current value expression is not valid JavaScript, then - // assume that the user did not end the value. To enforce this, - // we call `self.assertExpression(val, true)`, but since the other - // tests are much faster, we run the other tests first. - - if (whitespaceRe.test(str[i])) { - // find the first non-whitespace character - for (var x = i; x < str.length; x++) { - if (!whitespaceRe.test(str[x])) { - // if it is a JavaScript punctuator, then assume that it is - // a part of the value - return (!characterParser.isPunctuator(str[x]) || quoteRe.test(str[x]) || str[x] === ':') && self.assertExpression(val, true); - } - } + + // if everything else is whitespace, return now so last attribute + // does not include trailing whitespace + if(done || x === str.length){ + break; } - // if there's no whitespace and the character is not ',', the - // attribute did not end. - return str[i] === ',' && self.assertExpression(val, true); + } + + // if there's no whitespace and the character is not ',', the + // attribute did not end. + if(str[i] === ',' && this.assertExpression(val, true)){ + break; } } + + state = characterParser.parseChar(str[i], state); + val += str[i]; + + if (str[i] === '\n') { + line++; + col = 1; + } else { + col++; + } + } + + this.assertExpression(val); + + this.lineno = line; + this.colno = col; + + tok.val = val; + tok.mustEscape = escapeAttr; + + return str.substr(i); + }, - for (var i = 0; i <= str.length; i++) { - if (isEndOfAttribute.call(this, i)) { - if (val.trim()) { - var saved = this.colno; - this.colno = colnoBeginVal; - this.assertExpression(val); - this.colno = saved; - } - - val = val.trim(); - - key = key.trim(); - key = key.replace(/^['"]|['"]$/g, ''); + /** + * Attributes. + */ + + attrs: function() { + var tok; + + if ('(' == this.input.charAt(0)) { + tok = this.tok('start-attributes'); + var index = this.bracketExpression().end; + var str = this.input.substr(1, index-1); - var tok = this.tok('attribute'); - tok.name = key; - tok.val = '' == val ? true : val; - tok.col = colnoBeginAttr; - tok.mustEscape = escapedAttr; - this.tokens.push(tok); + this.incrementColumn(1); + this.tokens.push(this.tokEnd(tok)); + this.assertNestingCorrect(str); + this.consume(index + 1); - key = val = ''; - loc = 'key'; - escapedAttr = false; - this.lineno = lineno; - } else { - switch (loc) { - case 'key-char': - if (str[i] === quote) { - loc = 'key'; - if (i + 1 < str.length && !/[ ,!=\n\t]/.test(str[i + 1])) - this.error('INVALID_KEY_CHARACTER', 'Unexpected character "' + str[i + 1] + '" expected ` `, `\\n`, `\t`, `,`, `!` or `=`'); - } else { - key += str[i]; - } - break; - case 'key': - if (key === '' && quoteRe.test(str[i])) { - loc = 'key-char'; - quote = str[i]; - } else if (str[i] === '!' || str[i] === '=') { - escapedAttr = str[i] !== '!'; - if (str[i] === '!') { - this.incrementColumn(1); - i++; - } - if (str[i] !== '=') this.error('INVALID_KEY_CHARACTER', 'Unexpected character ' + str[i] + ' expected `=`'); - loc = 'value'; - colnoBeginVal = this.colno + 1; - state = characterParser.defaultState(); - } else { - key += str[i] - } - break; - case 'value': - state = characterParser.parseChar(str[i], state); - val += str[i]; - break; - } - } - if (str[i] === '\n') { - // Save the line number locally to keep this.lineno at the start of - // the attribute. - lineno++; - this.colno = 1; - // If the key has not been started, update this.lineno immediately. - if (!key.trim()) this.lineno = lineno; - } else if (str[i] !== undefined) { - this.incrementColumn(1); - } + while(str){ + str = this.attributeName(str); } - // Reset the line numbers based on the line started on - // plus the number of newline characters encountered - this.lineno = startingLine + (str.match(/\n/g) || []).length; - - this.tokens.push(this.tok('end-attributes')); + tok = this.tok('end-attributes'); this.incrementColumn(1); + this.tokEnd(tok); + this.tokens.push(tok); return true; } }, @@ -1173,8 +1301,8 @@ Lexer.prototype = { consumed = args.end + 1; this.consume(consumed); tok.val = args.src; - this.tokens.push(tok); this.incrementColumn(consumed); + this.tokens.push(this.tokEnd(tok)); return true; } }, @@ -1185,6 +1313,7 @@ Lexer.prototype = { indent: function() { var captures = this.scanIndentation(); + var tok; if (captures) { var indents = captures[1].length; @@ -1199,28 +1328,36 @@ Lexer.prototype = { // blank line if ('\n' == this.input[0]) { this.interpolationAllowed = true; - return this.tok('newline'); + return this.tokEnd(this.tok('newline')); } // outdent if (indents < this.indentStack[0]) { + var outdent_count = 0; while (this.indentStack[0] > indents) { if (this.indentStack[1] < indents) { this.error('INCONSISTENT_INDENTATION', 'Inconsistent indentation. Expecting either ' + this.indentStack[1] + ' or ' + this.indentStack[0] + ' spaces/tabs.'); } - this.colno = this.indentStack[1] + 1; - this.tokens.push(this.tok('outdent')); + outdent_count++; this.indentStack.shift(); } + while(outdent_count--){ + this.colno = 1; + tok = this.tok('outdent'); + this.colno = this.indentStack[0] + 1; + this.tokens.push(this.tokEnd(tok)); + } // indent } else if (indents && indents != this.indentStack[0]) { - this.tokens.push(this.tok('indent', indents)); + tok = this.tok('indent', indents); this.colno = 1 + indents; + this.tokens.push(this.tokEnd(tok)); this.indentStack.unshift(indents); // newline } else { - this.tokens.push(this.tok('newline')); - this.colno = 1 + (this.indentStack[0] || 0); + tok = this.tok('newline'); + this.colno = 1 + Math.min(this.indentStack[0] || 0, indents); + this.tokens.push(this.tokEnd(tok)); } this.interpolationAllowed = true; @@ -1235,8 +1372,9 @@ Lexer.prototype = { indents = indents || captures && captures[1].length; if (indents > this.indentStack[0]) { - this.tokens.push(this.tok('start-pipeless-text')); + this.tokens.push(this.tokEnd(this.tok('start-pipeless-text'))); var tokens = []; + var token_indent = []; var isMatch; // Index in this.input. Can't use this.consume because we might need to // retry lexing the block. @@ -1248,7 +1386,9 @@ Lexer.prototype = { var str = this.input.substr(stringPtr + 1, i); var lineCaptures = this.indentRe.exec('\n' + str); var lineIndents = lineCaptures && lineCaptures[1].length; - isMatch = lineIndents >= indents || !str.trim(); + isMatch = lineIndents >= indents; + token_indent.push(isMatch); + isMatch = isMatch || !str.trim(); if (isMatch) { // consume test along with `\n` prefix if match stringPtr += str.length + 1; @@ -1263,12 +1403,14 @@ Lexer.prototype = { this.consume(stringPtr); while (this.input.length === 0 && tokens[tokens.length - 1] === '') tokens.pop(); tokens.forEach(function (token, i) { + var tok; this.incrementLine(1); - if (i !== 0) this.tokens.push(this.tok('newline')); - this.incrementColumn(indents); + if (i !== 0) tok = this.tok('newline'); + if (token_indent[i]) this.incrementColumn(indents); + if (tok) this.tokens.push(this.tokEnd(tok)); this.addText('text', token); }.bind(this)); - this.tokens.push(this.tok('end-pipeless-text')); + this.tokens.push(this.tokEnd(this.tok('end-pipeless-text'))); return true; } }, @@ -1280,7 +1422,7 @@ Lexer.prototype = { slash: function() { var tok = this.scan(/^\//, 'slash'); if (tok) { - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); return true; } }, @@ -1292,7 +1434,7 @@ Lexer.prototype = { colon: function() { var tok = this.scan(/^: +/, ':'); if (tok) { - this.tokens.push(tok); + this.tokens.push(this.tokEnd(tok)); return true; } }, From 1d9e1be38236e2b223da873c326828f952fbc00f Mon Sep 17 00:00:00 2001 From: Joshua Sullivan Date: Mon, 12 Feb 2018 08:12:53 -0800 Subject: [PATCH 3/7] Update pug-parser and pug to use new `loc` attribute on tokens --- packages/pug-parser/index.js | 196 +++++++++++++++++------------------ packages/pug/lib/index.js | 3 +- 2 files changed, 99 insertions(+), 100 deletions(-) diff --git a/packages/pug-parser/index.js b/packages/pug-parser/index.js index fe93b92e9..9036ca3bf 100644 --- a/packages/pug-parser/index.js +++ b/packages/pug-parser/index.js @@ -51,8 +51,8 @@ Parser.prototype = { error: function (code, message, token) { var err = error(code, message, { - line: token.line, - column: token.col, + line: token.loc.start.line, + column: token.loc.start.column, filename: this.filename, src: this.src }); @@ -229,7 +229,7 @@ Parser.prototype = { case 'start-pug-interpolation': return this.parseText({block: true}); case 'text-html': - return this.initBlock(this.peek().line, this.parseTextHtml()); + return this.initBlock(this.peek().loc.start.line, this.parseTextHtml()); case 'dot': return this.parseDot(); case 'each': @@ -250,11 +250,11 @@ Parser.prototype = { return this.parseYield(); case 'id': case 'class': + if (!this.peek().loc.start) debugger; this.tokens.defer({ type: 'tag', val: 'div', - line: this.peek().line, - col: this.peek().col, + loc: this.peek().loc, filename: this.filename }); return this.parseExpr(); @@ -276,7 +276,7 @@ Parser.prototype = { parseText: function(options){ var tags = []; - var lineno = this.peek().line; + var lineno = this.peek().loc.start.line; var nextTok = this.peek(); loop: while (true) { @@ -286,8 +286,8 @@ Parser.prototype = { tags.push({ type: 'Text', val: tok.val, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }); break; @@ -299,8 +299,8 @@ Parser.prototype = { buffer: tok.buffer, mustEscape: tok.mustEscape !== false, isInline: true, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }); break; @@ -312,8 +312,8 @@ Parser.prototype = { tags.push({ type: 'Text', val: '\n', - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }); } @@ -347,8 +347,8 @@ loop: type: 'Text', val: text.val, filename: this.filename, - line: text.line, - column: text.col, + line: text.loc.start.line, + column: text.loc.start.column, isHtml: true }; nodes.push(currentNode); @@ -395,7 +395,7 @@ loop: var tok = this.accept(':'); if (tok) { var expr = this.parseExpr(); - return expr.type === 'Block' ? expr : this.initBlock(tok.line, [expr]); + return expr.type === 'Block' ? expr : this.initBlock(tok.loc.start.line, [expr]); } else { return this.block(); } @@ -410,12 +410,12 @@ loop: var node = { type: 'Case', expr: tok.val, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; - var block = this.emptyBlock(tok.line + 1); + var block = this.emptyBlock(tok.loc.start.line + 1); this.expect('indent'); while ('outdent' != this.peek().type) { switch (this.peek().type) { @@ -455,8 +455,8 @@ loop: expr: tok.val, block: this.parseBlockExpansion(), debug: false, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; } else { @@ -464,8 +464,8 @@ loop: type: 'When', expr: tok.val, debug: false, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; } @@ -482,8 +482,8 @@ loop: expr: 'default', block: this.parseBlockExpansion(), debug: false, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; }, @@ -501,8 +501,8 @@ loop: buffer: tok.buffer, mustEscape: tok.mustEscape !== false, isInline: !!noBlock, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; // todo: why is this here? It seems like a hacky workaround @@ -528,10 +528,10 @@ loop: var node = { type: 'Conditional', test: tok.val, - consequent: this.emptyBlock(tok.line), + consequent: this.emptyBlock(tok.loc.start.line), alternate: null, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; @@ -550,10 +550,10 @@ loop: currentNode.alternate = { type: 'Conditional', test: tok.val, - consequent: this.emptyBlock(tok.line), + consequent: this.emptyBlock(tok.loc.start.line), alternate: null, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename } ); @@ -578,8 +578,8 @@ loop: var node = { type: 'While', test: tok.val, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; @@ -587,7 +587,7 @@ loop: if ('indent' == this.peek().type) { node.block = this.block(); } else { - node.block = this.emptyBlock(tok.line); + node.block = this.emptyBlock(tok.loc.start.line); } return node; @@ -599,8 +599,8 @@ loop: parseBlockCode: function(){ var tok = this.expect('blockcode'); - var line = tok.line; - var column = tok.col; + var line = tok.loc.start.line; + var column = tok.loc.start.column; var body = this.peek(); var text = ''; if (body.type === 'start-pipeless-text') { @@ -649,8 +649,8 @@ loop: val: tok.val, block: block, buffer: tok.buffer, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; } else { @@ -658,8 +658,8 @@ loop: type: 'Comment', val: tok.val, buffer: tok.buffer, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; } @@ -674,8 +674,8 @@ loop: return { type: 'Doctype', val: tok.val, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; }, @@ -692,8 +692,8 @@ loop: type: 'IncludeFilter', name: tok.val, attrs: attrs, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; }, @@ -712,19 +712,19 @@ loop: if (this.peek().type === 'text') { var textToken = this.advance(); - block = this.initBlock(textToken.line, [ + block = this.initBlock(textToken.loc.start.line, [ { type: 'Text', val: textToken.val, - line: textToken.line, - column: textToken.col, + line: textToken.loc.start.line, + column: textToken.loc.start.column, filename: this.filename } ]); } else if (this.peek().type === 'filter') { - block = this.initBlock(tok.line, [this.parseFilter()]); + block = this.initBlock(tok.loc.start.line, [this.parseFilter()]); } else { - block = this.parseTextBlock() || this.emptyBlock(tok.line); + block = this.parseTextBlock() || this.emptyBlock(tok.loc.start.line); } return { @@ -732,8 +732,8 @@ loop: name: tok.val, block: block, attrs: attrs, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; }, @@ -750,8 +750,8 @@ loop: val: tok.val, key: tok.key, block: this.block(), - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; if (this.peek().type == 'else') { @@ -773,12 +773,12 @@ loop: file: { type: 'FileReference', path: path.val.trim(), - line: path.line, - column: path.col, + line: path.loc.start.line, + column: path.loc.start.column, filename: this.filename }, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; }, @@ -790,12 +790,12 @@ loop: parseBlock: function(){ var tok = this.expect('block'); - var node = 'indent' == this.peek().type ? this.block() : this.emptyBlock(tok.line); + var node = 'indent' == this.peek().type ? this.block() : this.emptyBlock(tok.loc.start.line); node.type = 'NamedBlock'; node.name = tok.val.trim(); node.mode = tok.mode; - node.line = tok.line; - node.column = tok.col; + node.line = tok.loc.start.line; + node.column = tok.loc.start.column; return node; }, @@ -807,8 +807,8 @@ loop: } return { type: 'MixinBlock', - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; }, @@ -817,8 +817,8 @@ loop: var tok = this.expect('yield'); return { type: 'YieldBlock', - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; }, @@ -835,8 +835,8 @@ loop: type: 'FileReference', filename: this.filename }, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; var filters = []; @@ -846,14 +846,14 @@ loop: var path = this.expect('path'); node.file.path = path.val.trim(); - node.file.line = path.line; - node.file.column = path.col; + node.file.line = path.loc.start.line; + node.file.column = path.loc.start.column; if ((/\.jade$/.test(node.file.path) || /\.pug$/.test(node.file.path)) && !filters.length) { - node.block = 'indent' == this.peek().type ? this.block() : this.emptyBlock(tok.line); + node.block = 'indent' == this.peek().type ? this.block() : this.emptyBlock(tok.loc.start.line); if (/\.jade$/.test(node.file.path)) { console.warn( - this.filename + ', line ' + tok.line + + this.filename + ', line ' + tok.loc.start.line + ':\nThe .jade extension is deprecated, use .pug for "' + node.file.path +'".' ); } @@ -879,12 +879,12 @@ loop: type: 'Mixin', name: name, args: args, - block: this.emptyBlock(tok.line), + block: this.emptyBlock(tok.loc.start.line), call: true, attrs: [], attributeBlocks: [], - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; @@ -914,8 +914,8 @@ loop: args: args, block: this.block(), call: false, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; this.inMixin--; @@ -932,7 +932,7 @@ loop: parseTextBlock: function(){ var tok = this.accept('start-pipeless-text'); if (!tok) return; - var block = this.emptyBlock(tok.line); + var block = this.emptyBlock(tok.loc.start.line); while (this.peek().type !== 'end-pipeless-text') { var tok = this.advance(); switch (tok.type) { @@ -940,8 +940,8 @@ loop: block.nodes.push({ type: 'Text', val: tok.val, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }); break; @@ -949,8 +949,8 @@ loop: block.nodes.push({ type: 'Text', val: '\n', - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }); break; @@ -965,8 +965,8 @@ loop: buffer: tok.buffer, mustEscape: tok.mustEscape !== false, isInline: true, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }); break; @@ -986,7 +986,7 @@ loop: block: function(){ var tok = this.expect('indent'); - var block = this.emptyBlock(tok.line); + var block = this.emptyBlock(tok.loc.start.line); while ('outdent' != this.peek().type) { if ('newline' == this.peek().type) { this.advance(); @@ -1015,12 +1015,12 @@ loop: type: 'InterpolatedTag', expr: tok.val, selfClosing: false, - block: this.emptyBlock(tok.line), + block: this.emptyBlock(tok.loc.start.line), attrs: [], attributeBlocks: [], isInline: false, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; @@ -1037,12 +1037,12 @@ loop: type: 'Tag', name: tok.val, selfClosing: false, - block: this.emptyBlock(tok.line), + block: this.emptyBlock(tok.loc.start.line), attrs: [], attributeBlocks: [], isInline: inlineTags.indexOf(tok.val) !== -1, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }; @@ -1073,15 +1073,15 @@ loop: tag.attrs.push({ name: tok.type, val: "'" + tok.val + "'", - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename, mustEscape: false }); continue; case 'start-attributes': if (seenAttrs) { - console.warn(this.filename + ', line ' + this.peek().line + ':\nYou should not have pug tags with multiple attributes.'); + console.warn(this.filename + ', line ' + this.peek().loc.start.line + ':\nYou should not have pug tags with multiple attributes.'); } seenAttrs = true; tag.attrs = tag.attrs.concat(this.attrs(attributeNames)); @@ -1091,8 +1091,8 @@ loop: tag.attributeBlocks.push({ type: 'AttributeBlock', val: tok.val, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename }); break; @@ -1178,8 +1178,8 @@ loop: attrs.push({ name: tok.name, val: tok.val, - line: tok.line, - column: tok.col, + line: tok.loc.start.line, + column: tok.loc.start.column, filename: this.filename, mustEscape: tok.mustEscape !== false }); @@ -1189,4 +1189,4 @@ loop: this.expect('end-attributes'); return attrs; } -}; +}; \ No newline at end of file diff --git a/packages/pug/lib/index.js b/packages/pug/lib/index.js index a3c8968a5..36b40f64d 100644 --- a/packages/pug/lib/index.js +++ b/packages/pug/lib/index.js @@ -103,8 +103,7 @@ function compileBody(str, options){ if (token.type === 'path' && path.extname(token.val) === '') { return { type: 'path', - line: token.line, - col: token.col, + loc: token.loc, val: token.val + '.pug' }; } From 2327eb2334bf7caae297c4b6f87d287f33a11ed8 Mon Sep 17 00:00:00 2001 From: Joshua Sullivan Date: Mon, 12 Feb 2018 08:18:05 -0800 Subject: [PATCH 4/7] Update parser test cases to have new `loc` attribute on tokens --- .../test/cases/attr-es2015.tokens.json | 18 +- .../test/cases/attrs-data.tokens.json | 66 ++-- .../test/cases/attrs.js.tokens.json | 156 ++++---- .../pug-parser/test/cases/attrs.tokens.json | 360 +++++++++--------- .../test/cases/attrs.unescaped.tokens.json | 30 +- .../pug-parser/test/cases/basic.tokens.json | 18 +- .../pug-parser/test/cases/blanks.tokens.json | 26 +- .../test/cases/block-code.tokens.json | 56 +-- .../block-expansion.shorthands.tokens.json | 22 +- .../test/cases/block-expansion.tokens.json | 42 +- .../test/cases/blockquote.tokens.json | 20 +- .../test/cases/blocks-in-blocks.tokens.json | 18 +- .../test/cases/blocks-in-if.tokens.json | 88 ++--- .../test/cases/case-blocks.tokens.json | 58 +-- .../pug-parser/test/cases/case.tokens.json | 108 +++--- .../test/cases/classes-empty.tokens.json | 30 +- .../pug-parser/test/cases/classes.tokens.json | 48 ++- .../test/cases/code.conditionals.tokens.json | 172 ++++----- .../test/cases/code.escape.tokens.json | 12 +- .../test/cases/code.iteration.tokens.json | 142 +++---- .../pug-parser/test/cases/code.tokens.json | 80 ++-- .../test/cases/comments-in-case.tokens.json | 52 +-- .../test/cases/comments.source.tokens.json | 36 +- .../test/cases/comments.tokens.json | 122 +++--- .../test/cases/doctype.custom.tokens.json | 4 +- .../test/cases/doctype.default.tokens.json | 22 +- .../test/cases/doctype.keyword.tokens.json | 4 +- .../test/cases/each.else.tokens.json | 176 ++++----- .../test/cases/escape-chars.tokens.json | 12 +- .../test/cases/escape-test.tokens.json | 40 +- .../escaping-class-attribute.tokens.json | 62 +-- .../test/cases/filter-in-include.tokens.json | 8 +- .../test/cases/filters-empty.tokens.json | 32 +- .../cases/filters.coffeescript.tokens.json | 42 +- .../test/cases/filters.custom.tokens.json | 42 +- .../cases/filters.include.custom.tokens.json | 34 +- .../test/cases/filters.include.tokens.json | 60 +-- .../test/cases/filters.inline.tokens.json | 16 +- .../test/cases/filters.less.tokens.json | 46 +-- .../test/cases/filters.markdown.tokens.json | 26 +- .../test/cases/filters.nested.tokens.json | 52 +-- .../test/cases/filters.stylus.tokens.json | 40 +- .../test/cases/filters.verbatim.tokens.json | 13 + .../pug-parser/test/cases/html.tokens.json | 52 +-- .../pug-parser/test/cases/html5.tokens.json | 40 +- .../include-extends-from-root.tokens.json | 8 +- ...ude-extends-of-common-template.tokens.json | 14 +- .../include-extends-relative.tokens.json | 8 +- .../cases/include-only-text-body.tokens.json | 14 +- .../test/cases/include-only-text.tokens.json | 32 +- .../cases/include-with-text-head.tokens.json | 24 +- .../test/cases/include-with-text.tokens.json | 34 +- .../test/cases/include.script.tokens.json | 20 +- .../cases/include.yield.nested.tokens.json | 22 +- .../cases/includes-with-ext-js.tokens.json | 18 +- .../test/cases/includes.tokens.json | 50 +-- .../inheritance.alert-dialog.tokens.json | 26 +- .../cases/inheritance.defaults.tokens.json | 48 +-- .../inheritance.extend.include.tokens.json | 56 +-- ...nheritance.extend.mixins.block.tokens.json | 18 +- .../inheritance.extend.mixins.tokens.json | 44 +-- .../inheritance.extend.recursive.tokens.json | 18 +- .../test/cases/inheritance.extend.tokens.json | 40 +- .../inheritance.extend.whitespace.tokens.json | 40 +- .../test/cases/inheritance.tokens.json | 40 +- .../cases/inline-block-comment.tokens.json | 20 +- .../test/cases/inline-tag.tokens.json | 154 ++++---- .../cases/intepolated-elements.tokens.json | 76 ++-- .../test/cases/interpolated-mixin.tokens.json | 30 +- .../cases/interpolation.escape.tokens.json | 30 +- .../test/cases/layout.append.tokens.json | 34 +- .../layout.append.without-block.tokens.json | 34 +- ...out.multi.append.prepend.block.tokens.json | 92 ++--- .../test/cases/layout.prepend.tokens.json | 34 +- .../layout.prepend.without-block.tokens.json | 34 +- .../cases/mixin-at-end-of-file.tokens.json | 18 +- .../cases/mixin-block-with-space.tokens.json | 24 +- .../test/cases/mixin-hoist.tokens.json | 28 +- .../test/cases/mixin-via-include.tokens.json | 14 +- .../test/cases/mixin.attrs.tokens.json | 322 ++++++++-------- .../mixin.block-tag-behaviour.tokens.json | 112 +++--- .../test/cases/mixin.blocks.tokens.json | 216 +++++------ .../test/cases/mixin.merge.tokens.json | 116 +++--- .../test/cases/mixins-unused.tokens.json | 14 +- .../test/cases/mixins.rest-args.tokens.json | 28 +- .../pug-parser/test/cases/mixins.tokens.json | 130 +++---- .../test/cases/namespaces.tokens.json | 16 +- .../pug-parser/test/cases/nesting.tokens.json | 46 +-- .../test/cases/pipeless-comments.tokens.json | 18 +- .../test/cases/pipeless-filters.tokens.json | 18 +- .../test/cases/pipeless-tag.tokens.json | 28 +- .../pug-parser/test/cases/pre.tokens.json | 50 +-- .../pug-parser/test/cases/quotes.tokens.json | 12 +- .../test/cases/regression.1794.tokens.json | 18 +- .../test/cases/regression.784.tokens.json | 10 +- .../test/cases/script.whitespace.tokens.json | 28 +- .../test/cases/scripts.non-js.tokens.json | 58 +-- .../pug-parser/test/cases/scripts.tokens.json | 40 +- .../test/cases/self-closing-html.tokens.json | 22 +- .../test/cases/single-period.tokens.json | 6 +- .../pug-parser/test/cases/source.tokens.json | 42 +- .../pug-parser/test/cases/styles.tokens.json | 128 +++---- .../test/cases/tag-blocks.tokens.json | 32 +- .../test/cases/tag.interpolation.tokens.json | 132 +++---- .../test/cases/tags.self-closing.tokens.json | 120 +++--- .../test/cases/template.tokens.json | 54 +-- .../test/cases/text-block.tokens.json | 40 +- .../pug-parser/test/cases/text.tokens.json | 182 ++++----- .../pug-parser/test/cases/utf8bom.tokens.json | 8 +- .../pug-parser/test/cases/vars.tokens.json | 20 +- .../pug-parser/test/cases/while.tokens.json | 26 +- .../pug-parser/test/cases/xml.tokens.json | 22 +- .../yield-before-conditional-head.tokens.json | 36 +- .../yield-before-conditional.tokens.json | 40 +- .../test/cases/yield-head.tokens.json | 30 +- .../test/cases/yield-title-head.tokens.json | 34 +- .../test/cases/yield-title.tokens.json | 24 +- .../pug-parser/test/cases/yield.tokens.json | 40 +- 118 files changed, 3075 insertions(+), 3042 deletions(-) create mode 100644 packages/pug-parser/test/cases/filters.verbatim.tokens.json diff --git a/packages/pug-parser/test/cases/attr-es2015.tokens.json b/packages/pug-parser/test/cases/attr-es2015.tokens.json index 274f22690..8616bc66e 100644 --- a/packages/pug-parser/test/cases/attr-es2015.tokens.json +++ b/packages/pug-parser/test/cases/attr-es2015.tokens.json @@ -1,9 +1,9 @@ -{"type":"code","line":1,"col":1,"val":"var avatar = '219b77f9d21de75e81851b6b886057c7'","mustEscape":false,"buffer":false} -{"type":"newline","line":3,"col":1} -{"type":"tag","line":3,"col":1,"val":"div"} -{"type":"class","line":3,"col":4,"val":"avatar-div"} -{"type":"start-attributes","line":3,"col":15} -{"type":"attribute","line":3,"col":16,"name":"style","val":"`background-image: url(https://www.gravatar.com/avatar/${avatar})`","mustEscape":true} -{"type":"end-attributes","line":3,"col":88} -{"type":"newline","line":4,"col":1} -{"type":"eos","line":4,"col":1} \ No newline at end of file +{"type":"code","loc":{"start":{"line":1,"column":1},"filename":"/cases/attr-es2015.pug","end":{"line":1,"column":50}},"val":"var avatar = '219b77f9d21de75e81851b6b886057c7'","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":3,"column":1},"filename":"/cases/attr-es2015.pug","end":{"line":3,"column":1}}} +{"type":"tag","loc":{"start":{"line":3,"column":1},"filename":"/cases/attr-es2015.pug","end":{"line":3,"column":4}},"val":"div"} +{"type":"class","loc":{"start":{"line":3,"column":4},"filename":"/cases/attr-es2015.pug","end":{"line":3,"column":15}},"val":"avatar-div"} +{"type":"start-attributes","loc":{"start":{"line":3,"column":15},"filename":"/cases/attr-es2015.pug","end":{"line":3,"column":16}}} +{"type":"attribute","loc":{"start":{"line":3,"column":16},"filename":"/cases/attr-es2015.pug","end":{"line":3,"column":88}},"name":"style","mustEscape":true,"val":"`background-image: url(https://www.gravatar.com/avatar/${avatar})`"} +{"type":"end-attributes","loc":{"start":{"line":3,"column":88},"filename":"/cases/attr-es2015.pug","end":{"line":3,"column":89}}} +{"type":"newline","loc":{"start":{"line":4,"column":1},"filename":"/cases/attr-es2015.pug","end":{"line":4,"column":1}}} +{"type":"eos","loc":{"start":{"line":4,"column":1},"filename":"/cases/attr-es2015.pug","end":{"line":4,"column":1}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/attrs-data.tokens.json b/packages/pug-parser/test/cases/attrs-data.tokens.json index d81f4772c..8f4ee0245 100644 --- a/packages/pug-parser/test/cases/attrs-data.tokens.json +++ b/packages/pug-parser/test/cases/attrs-data.tokens.json @@ -1,33 +1,33 @@ -{"type":"code","line":1,"col":1,"val":"var user = { name: 'tobi' }","mustEscape":false,"buffer":false} -{"type":"newline","line":2,"col":1} -{"type":"tag","line":2,"col":1,"val":"foo"} -{"type":"start-attributes","line":2,"col":4} -{"type":"attribute","line":2,"col":5,"name":"data-user","val":"user","mustEscape":true} -{"type":"end-attributes","line":2,"col":19} -{"type":"newline","line":3,"col":1} -{"type":"tag","line":3,"col":1,"val":"foo"} -{"type":"start-attributes","line":3,"col":4} -{"type":"attribute","line":3,"col":5,"name":"data-items","val":"[1,2,3]","mustEscape":true} -{"type":"end-attributes","line":3,"col":23} -{"type":"newline","line":4,"col":1} -{"type":"tag","line":4,"col":1,"val":"foo"} -{"type":"start-attributes","line":4,"col":4} -{"type":"attribute","line":4,"col":5,"name":"data-username","val":"'tobi'","mustEscape":true} -{"type":"end-attributes","line":4,"col":25} -{"type":"newline","line":5,"col":1} -{"type":"tag","line":5,"col":1,"val":"foo"} -{"type":"start-attributes","line":5,"col":4} -{"type":"attribute","line":5,"col":5,"name":"data-escaped","val":"{message: \"Let's rock!\"}","mustEscape":true} -{"type":"end-attributes","line":5,"col":42} -{"type":"newline","line":6,"col":1} -{"type":"tag","line":6,"col":1,"val":"foo"} -{"type":"start-attributes","line":6,"col":4} -{"type":"attribute","line":6,"col":5,"name":"data-ampersand","val":"{message: \"a quote: " this & that\"}","mustEscape":true} -{"type":"end-attributes","line":6,"col":60} -{"type":"newline","line":7,"col":1} -{"type":"tag","line":7,"col":1,"val":"foo"} -{"type":"start-attributes","line":7,"col":4} -{"type":"attribute","line":7,"col":5,"name":"data-epoc","val":"new Date(0)","mustEscape":true} -{"type":"end-attributes","line":7,"col":26} -{"type":"newline","line":8,"col":1} -{"type":"eos","line":8,"col":1} \ No newline at end of file +{"type":"code","loc":{"start":{"line":1,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":1,"column":30}},"val":"var user = { name: 'tobi' }","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":2,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":2,"column":1}}} +{"type":"tag","loc":{"start":{"line":2,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":2,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":2,"column":4},"filename":"/cases/attrs-data.pug","end":{"line":2,"column":5}}} +{"type":"attribute","loc":{"start":{"line":2,"column":5},"filename":"/cases/attrs-data.pug","end":{"line":2,"column":19}},"name":"data-user","mustEscape":true,"val":"user"} +{"type":"end-attributes","loc":{"start":{"line":2,"column":19},"filename":"/cases/attrs-data.pug","end":{"line":2,"column":20}}} +{"type":"newline","loc":{"start":{"line":3,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":3,"column":1}}} +{"type":"tag","loc":{"start":{"line":3,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":3,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":3,"column":4},"filename":"/cases/attrs-data.pug","end":{"line":3,"column":5}}} +{"type":"attribute","loc":{"start":{"line":3,"column":5},"filename":"/cases/attrs-data.pug","end":{"line":3,"column":23}},"name":"data-items","mustEscape":true,"val":"[1,2,3]"} +{"type":"end-attributes","loc":{"start":{"line":3,"column":23},"filename":"/cases/attrs-data.pug","end":{"line":3,"column":24}}} +{"type":"newline","loc":{"start":{"line":4,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":4,"column":1}}} +{"type":"tag","loc":{"start":{"line":4,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":4,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":4,"column":4},"filename":"/cases/attrs-data.pug","end":{"line":4,"column":5}}} +{"type":"attribute","loc":{"start":{"line":4,"column":5},"filename":"/cases/attrs-data.pug","end":{"line":4,"column":25}},"name":"data-username","mustEscape":true,"val":"'tobi'"} +{"type":"end-attributes","loc":{"start":{"line":4,"column":25},"filename":"/cases/attrs-data.pug","end":{"line":4,"column":26}}} +{"type":"newline","loc":{"start":{"line":5,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":5,"column":1}}} +{"type":"tag","loc":{"start":{"line":5,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":5,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":5,"column":4},"filename":"/cases/attrs-data.pug","end":{"line":5,"column":5}}} +{"type":"attribute","loc":{"start":{"line":5,"column":5},"filename":"/cases/attrs-data.pug","end":{"line":5,"column":42}},"name":"data-escaped","mustEscape":true,"val":"{message: \"Let's rock!\"}"} +{"type":"end-attributes","loc":{"start":{"line":5,"column":42},"filename":"/cases/attrs-data.pug","end":{"line":5,"column":43}}} +{"type":"newline","loc":{"start":{"line":6,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":6,"column":1}}} +{"type":"tag","loc":{"start":{"line":6,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":6,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":6,"column":4},"filename":"/cases/attrs-data.pug","end":{"line":6,"column":5}}} +{"type":"attribute","loc":{"start":{"line":6,"column":5},"filename":"/cases/attrs-data.pug","end":{"line":6,"column":60}},"name":"data-ampersand","mustEscape":true,"val":"{message: \"a quote: " this & that\"}"} +{"type":"end-attributes","loc":{"start":{"line":6,"column":60},"filename":"/cases/attrs-data.pug","end":{"line":6,"column":61}}} +{"type":"newline","loc":{"start":{"line":7,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":7,"column":1}}} +{"type":"tag","loc":{"start":{"line":7,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":7,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":7,"column":4},"filename":"/cases/attrs-data.pug","end":{"line":7,"column":5}}} +{"type":"attribute","loc":{"start":{"line":7,"column":5},"filename":"/cases/attrs-data.pug","end":{"line":7,"column":26}},"name":"data-epoc","mustEscape":true,"val":"new Date(0)"} +{"type":"end-attributes","loc":{"start":{"line":7,"column":26},"filename":"/cases/attrs-data.pug","end":{"line":7,"column":27}}} +{"type":"newline","loc":{"start":{"line":8,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":8,"column":1}}} +{"type":"eos","loc":{"start":{"line":8,"column":1},"filename":"/cases/attrs-data.pug","end":{"line":8,"column":1}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/attrs.js.tokens.json b/packages/pug-parser/test/cases/attrs.js.tokens.json index 7d8500073..7da64d970 100644 --- a/packages/pug-parser/test/cases/attrs.js.tokens.json +++ b/packages/pug-parser/test/cases/attrs.js.tokens.json @@ -1,78 +1,78 @@ -{"type":"code","line":1,"col":1,"val":"var id = 5","mustEscape":false,"buffer":false} -{"type":"newline","line":2,"col":1} -{"type":"code","line":2,"col":1,"val":"function answer() { return 42; }","mustEscape":false,"buffer":false} -{"type":"newline","line":3,"col":1} -{"type":"tag","line":3,"col":1,"val":"a"} -{"type":"start-attributes","line":3,"col":2} -{"type":"attribute","line":3,"col":3,"name":"href","val":"'/user/' + id","mustEscape":true} -{"type":"attribute","line":3,"col":23,"name":"class","val":"'button'","mustEscape":true} -{"type":"end-attributes","line":3,"col":37} -{"type":"newline","line":4,"col":1} -{"type":"tag","line":4,"col":1,"val":"a"} -{"type":"start-attributes","line":4,"col":2} -{"type":"attribute","line":4,"col":3,"name":"href","val":"'/user/' + id","mustEscape":true} -{"type":"attribute","line":4,"col":27,"name":"class","val":"'button'","mustEscape":true} -{"type":"end-attributes","line":4,"col":45} -{"type":"newline","line":5,"col":1} -{"type":"tag","line":5,"col":1,"val":"meta"} -{"type":"start-attributes","line":5,"col":5} -{"type":"attribute","line":5,"col":6,"name":"key","val":"'answer'","mustEscape":true} -{"type":"attribute","line":5,"col":20,"name":"value","val":"answer()","mustEscape":true} -{"type":"end-attributes","line":5,"col":34} -{"type":"newline","line":6,"col":1} -{"type":"tag","line":6,"col":1,"val":"a"} -{"type":"start-attributes","line":6,"col":2} -{"type":"attribute","line":6,"col":3,"name":"class","val":"['class1', 'class2']","mustEscape":true} -{"type":"end-attributes","line":6,"col":31} -{"type":"newline","line":7,"col":1} -{"type":"tag","line":7,"col":1,"val":"a"} -{"type":"class","line":7,"col":2,"val":"tag-class"} -{"type":"start-attributes","line":7,"col":12} -{"type":"attribute","line":7,"col":13,"name":"class","val":"['class1', 'class2']","mustEscape":true} -{"type":"end-attributes","line":7,"col":41} -{"type":"newline","line":9,"col":1} -{"type":"tag","line":9,"col":1,"val":"a"} -{"type":"start-attributes","line":9,"col":2} -{"type":"attribute","line":9,"col":3,"name":"href","val":"'/user/' + id","mustEscape":true} -{"type":"attribute","line":9,"col":22,"name":"class","val":"'button'","mustEscape":true} -{"type":"end-attributes","line":9,"col":36} -{"type":"newline","line":10,"col":1} -{"type":"tag","line":10,"col":1,"val":"a"} -{"type":"start-attributes","line":10,"col":2} -{"type":"attribute","line":10,"col":3,"name":"href","val":"'/user/' + id","mustEscape":true} -{"type":"attribute","line":10,"col":26,"name":"class","val":"'button'","mustEscape":true} -{"type":"end-attributes","line":10,"col":44} -{"type":"newline","line":11,"col":1} -{"type":"tag","line":11,"col":1,"val":"meta"} -{"type":"start-attributes","line":11,"col":5} -{"type":"attribute","line":11,"col":6,"name":"key","val":"'answer'","mustEscape":true} -{"type":"attribute","line":11,"col":19,"name":"value","val":"answer()","mustEscape":true} -{"type":"end-attributes","line":11,"col":33} -{"type":"newline","line":12,"col":1} -{"type":"tag","line":12,"col":1,"val":"a"} -{"type":"start-attributes","line":12,"col":2} -{"type":"attribute","line":12,"col":3,"name":"class","val":"['class1', 'class2']","mustEscape":true} -{"type":"end-attributes","line":12,"col":31} -{"type":"newline","line":13,"col":1} -{"type":"tag","line":13,"col":1,"val":"a"} -{"type":"class","line":13,"col":2,"val":"tag-class"} -{"type":"start-attributes","line":13,"col":12} -{"type":"attribute","line":13,"col":13,"name":"class","val":"['class1', 'class2']","mustEscape":true} -{"type":"end-attributes","line":13,"col":41} -{"type":"newline","line":15,"col":1} -{"type":"tag","line":15,"col":1,"val":"div"} -{"type":"start-attributes","line":15,"col":4} -{"type":"attribute","line":15,"col":5,"name":"id","val":"id","mustEscape":true} -{"type":"end-attributes","line":15,"col":10} -{"type":"&attributes","line":15,"col":11,"val":"{foo: 'bar'}"} -{"type":"newline","line":16,"col":1} -{"type":"code","line":16,"col":1,"val":"var bar = null","mustEscape":false,"buffer":false} -{"type":"newline","line":17,"col":1} -{"type":"tag","line":17,"col":1,"val":"div"} -{"type":"start-attributes","line":17,"col":4} -{"type":"attribute","line":17,"col":5,"name":"foo","val":"null","mustEscape":true} -{"type":"attribute","line":17,"col":14,"name":"bar","val":"bar","mustEscape":true} -{"type":"end-attributes","line":17,"col":21} -{"type":"&attributes","line":17,"col":22,"val":"{baz: 'baz'}"} -{"type":"newline","line":18,"col":1} -{"type":"eos","line":18,"col":1} \ No newline at end of file +{"type":"code","loc":{"start":{"line":1,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":1,"column":13}},"val":"var id = 5","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":2,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":2,"column":1}}} +{"type":"code","loc":{"start":{"line":2,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":2,"column":35}},"val":"function answer() { return 42; }","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":3,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":3,"column":1}}} +{"type":"tag","loc":{"start":{"line":3,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":3,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":3,"column":2},"filename":"/cases/attrs.js.pug","end":{"line":3,"column":3}}} +{"type":"attribute","loc":{"start":{"line":3,"column":3},"filename":"/cases/attrs.js.pug","end":{"line":3,"column":21}},"name":"href","mustEscape":true,"val":"'/user/' + id"} +{"type":"attribute","loc":{"start":{"line":3,"column":23},"filename":"/cases/attrs.js.pug","end":{"line":3,"column":37}},"name":"class","mustEscape":true,"val":"'button'"} +{"type":"end-attributes","loc":{"start":{"line":3,"column":37},"filename":"/cases/attrs.js.pug","end":{"line":3,"column":38}}} +{"type":"newline","loc":{"start":{"line":4,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":4,"column":1}}} +{"type":"tag","loc":{"start":{"line":4,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":4,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":4,"column":2},"filename":"/cases/attrs.js.pug","end":{"line":4,"column":3}}} +{"type":"attribute","loc":{"start":{"line":4,"column":3},"filename":"/cases/attrs.js.pug","end":{"line":4,"column":25}},"name":"href","mustEscape":true,"val":"'/user/' + id"} +{"type":"attribute","loc":{"start":{"line":4,"column":27},"filename":"/cases/attrs.js.pug","end":{"line":4,"column":45}},"name":"class","mustEscape":true,"val":"'button'"} +{"type":"end-attributes","loc":{"start":{"line":4,"column":45},"filename":"/cases/attrs.js.pug","end":{"line":4,"column":46}}} +{"type":"newline","loc":{"start":{"line":5,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":5,"column":1}}} +{"type":"tag","loc":{"start":{"line":5,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":5,"column":5}},"val":"meta"} +{"type":"start-attributes","loc":{"start":{"line":5,"column":5},"filename":"/cases/attrs.js.pug","end":{"line":5,"column":6}}} +{"type":"attribute","loc":{"start":{"line":5,"column":6},"filename":"/cases/attrs.js.pug","end":{"line":5,"column":18}},"name":"key","mustEscape":true,"val":"'answer'"} +{"type":"attribute","loc":{"start":{"line":5,"column":20},"filename":"/cases/attrs.js.pug","end":{"line":5,"column":34}},"name":"value","mustEscape":true,"val":"answer()"} +{"type":"end-attributes","loc":{"start":{"line":5,"column":34},"filename":"/cases/attrs.js.pug","end":{"line":5,"column":35}}} +{"type":"newline","loc":{"start":{"line":6,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":6,"column":1}}} +{"type":"tag","loc":{"start":{"line":6,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":6,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":6,"column":2},"filename":"/cases/attrs.js.pug","end":{"line":6,"column":3}}} +{"type":"attribute","loc":{"start":{"line":6,"column":3},"filename":"/cases/attrs.js.pug","end":{"line":6,"column":31}},"name":"class","mustEscape":true,"val":"['class1', 'class2']"} +{"type":"end-attributes","loc":{"start":{"line":6,"column":31},"filename":"/cases/attrs.js.pug","end":{"line":6,"column":32}}} +{"type":"newline","loc":{"start":{"line":7,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":7,"column":1}}} +{"type":"tag","loc":{"start":{"line":7,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":7,"column":2}},"val":"a"} +{"type":"class","loc":{"start":{"line":7,"column":2},"filename":"/cases/attrs.js.pug","end":{"line":7,"column":12}},"val":"tag-class"} +{"type":"start-attributes","loc":{"start":{"line":7,"column":12},"filename":"/cases/attrs.js.pug","end":{"line":7,"column":13}}} +{"type":"attribute","loc":{"start":{"line":7,"column":13},"filename":"/cases/attrs.js.pug","end":{"line":7,"column":41}},"name":"class","mustEscape":true,"val":"['class1', 'class2']"} +{"type":"end-attributes","loc":{"start":{"line":7,"column":41},"filename":"/cases/attrs.js.pug","end":{"line":7,"column":42}}} +{"type":"newline","loc":{"start":{"line":9,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":9,"column":1}}} +{"type":"tag","loc":{"start":{"line":9,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":9,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":9,"column":2},"filename":"/cases/attrs.js.pug","end":{"line":9,"column":3}}} +{"type":"attribute","loc":{"start":{"line":9,"column":3},"filename":"/cases/attrs.js.pug","end":{"line":9,"column":21}},"name":"href","mustEscape":true,"val":"'/user/' + id"} +{"type":"attribute","loc":{"start":{"line":9,"column":22},"filename":"/cases/attrs.js.pug","end":{"line":9,"column":36}},"name":"class","mustEscape":true,"val":"'button'"} +{"type":"end-attributes","loc":{"start":{"line":9,"column":36},"filename":"/cases/attrs.js.pug","end":{"line":9,"column":37}}} +{"type":"newline","loc":{"start":{"line":10,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":10,"column":1}}} +{"type":"tag","loc":{"start":{"line":10,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":10,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":10,"column":2},"filename":"/cases/attrs.js.pug","end":{"line":10,"column":3}}} +{"type":"attribute","loc":{"start":{"line":10,"column":3},"filename":"/cases/attrs.js.pug","end":{"line":10,"column":25}},"name":"href","mustEscape":true,"val":"'/user/' + id"} +{"type":"attribute","loc":{"start":{"line":10,"column":26},"filename":"/cases/attrs.js.pug","end":{"line":10,"column":44}},"name":"class","mustEscape":true,"val":"'button'"} +{"type":"end-attributes","loc":{"start":{"line":10,"column":44},"filename":"/cases/attrs.js.pug","end":{"line":10,"column":45}}} +{"type":"newline","loc":{"start":{"line":11,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":11,"column":1}}} +{"type":"tag","loc":{"start":{"line":11,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":11,"column":5}},"val":"meta"} +{"type":"start-attributes","loc":{"start":{"line":11,"column":5},"filename":"/cases/attrs.js.pug","end":{"line":11,"column":6}}} +{"type":"attribute","loc":{"start":{"line":11,"column":6},"filename":"/cases/attrs.js.pug","end":{"line":11,"column":18}},"name":"key","mustEscape":true,"val":"'answer'"} +{"type":"attribute","loc":{"start":{"line":11,"column":19},"filename":"/cases/attrs.js.pug","end":{"line":11,"column":33}},"name":"value","mustEscape":true,"val":"answer()"} +{"type":"end-attributes","loc":{"start":{"line":11,"column":33},"filename":"/cases/attrs.js.pug","end":{"line":11,"column":34}}} +{"type":"newline","loc":{"start":{"line":12,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":12,"column":1}}} +{"type":"tag","loc":{"start":{"line":12,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":12,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":12,"column":2},"filename":"/cases/attrs.js.pug","end":{"line":12,"column":3}}} +{"type":"attribute","loc":{"start":{"line":12,"column":3},"filename":"/cases/attrs.js.pug","end":{"line":12,"column":31}},"name":"class","mustEscape":true,"val":"['class1', 'class2']"} +{"type":"end-attributes","loc":{"start":{"line":12,"column":31},"filename":"/cases/attrs.js.pug","end":{"line":12,"column":32}}} +{"type":"newline","loc":{"start":{"line":13,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":13,"column":1}}} +{"type":"tag","loc":{"start":{"line":13,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":13,"column":2}},"val":"a"} +{"type":"class","loc":{"start":{"line":13,"column":2},"filename":"/cases/attrs.js.pug","end":{"line":13,"column":12}},"val":"tag-class"} +{"type":"start-attributes","loc":{"start":{"line":13,"column":12},"filename":"/cases/attrs.js.pug","end":{"line":13,"column":13}}} +{"type":"attribute","loc":{"start":{"line":13,"column":13},"filename":"/cases/attrs.js.pug","end":{"line":13,"column":41}},"name":"class","mustEscape":true,"val":"['class1', 'class2']"} +{"type":"end-attributes","loc":{"start":{"line":13,"column":41},"filename":"/cases/attrs.js.pug","end":{"line":13,"column":42}}} +{"type":"newline","loc":{"start":{"line":15,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":15,"column":1}}} +{"type":"tag","loc":{"start":{"line":15,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":15,"column":4}},"val":"div"} +{"type":"start-attributes","loc":{"start":{"line":15,"column":4},"filename":"/cases/attrs.js.pug","end":{"line":15,"column":5}}} +{"type":"attribute","loc":{"start":{"line":15,"column":5},"filename":"/cases/attrs.js.pug","end":{"line":15,"column":10}},"name":"id","mustEscape":true,"val":"id"} +{"type":"end-attributes","loc":{"start":{"line":15,"column":10},"filename":"/cases/attrs.js.pug","end":{"line":15,"column":11}}} +{"type":"&attributes","loc":{"start":{"line":15,"column":11},"filename":"/cases/attrs.js.pug","end":{"line":15,"column":36}},"val":"{foo: 'bar'}"} +{"type":"newline","loc":{"start":{"line":16,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":16,"column":1}}} +{"type":"code","loc":{"start":{"line":16,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":16,"column":17}},"val":"var bar = null","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":17,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":17,"column":1}}} +{"type":"tag","loc":{"start":{"line":17,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":17,"column":4}},"val":"div"} +{"type":"start-attributes","loc":{"start":{"line":17,"column":4},"filename":"/cases/attrs.js.pug","end":{"line":17,"column":5}}} +{"type":"attribute","loc":{"start":{"line":17,"column":5},"filename":"/cases/attrs.js.pug","end":{"line":17,"column":13}},"name":"foo","mustEscape":true,"val":"null"} +{"type":"attribute","loc":{"start":{"line":17,"column":14},"filename":"/cases/attrs.js.pug","end":{"line":17,"column":21}},"name":"bar","mustEscape":true,"val":"bar"} +{"type":"end-attributes","loc":{"start":{"line":17,"column":21},"filename":"/cases/attrs.js.pug","end":{"line":17,"column":22}}} +{"type":"&attributes","loc":{"start":{"line":17,"column":22},"filename":"/cases/attrs.js.pug","end":{"line":17,"column":47}},"val":"{baz: 'baz'}"} +{"type":"newline","loc":{"start":{"line":18,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":18,"column":1}}} +{"type":"eos","loc":{"start":{"line":18,"column":1},"filename":"/cases/attrs.js.pug","end":{"line":18,"column":1}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/attrs.tokens.json b/packages/pug-parser/test/cases/attrs.tokens.json index 32a0ad3c8..d15ce773c 100644 --- a/packages/pug-parser/test/cases/attrs.tokens.json +++ b/packages/pug-parser/test/cases/attrs.tokens.json @@ -1,180 +1,180 @@ -{"type":"tag","line":1,"col":1,"val":"a"} -{"type":"start-attributes","line":1,"col":2} -{"type":"attribute","line":1,"col":3,"name":"href","val":"'/contact'","mustEscape":true} -{"type":"end-attributes","line":1,"col":18} -{"type":"text","line":1,"col":20,"val":"contact"} -{"type":"newline","line":2,"col":1} -{"type":"tag","line":2,"col":1,"val":"a"} -{"type":"start-attributes","line":2,"col":2} -{"type":"attribute","line":2,"col":3,"name":"href","val":"'/save'","mustEscape":true} -{"type":"end-attributes","line":2,"col":15} -{"type":"class","line":2,"col":16,"val":"button"} -{"type":"text","line":2,"col":24,"val":"save"} -{"type":"newline","line":3,"col":1} -{"type":"tag","line":3,"col":1,"val":"a"} -{"type":"start-attributes","line":3,"col":2} -{"type":"attribute","line":3,"col":3,"name":"foo","val":true,"mustEscape":true} -{"type":"attribute","line":3,"col":8,"name":"bar","val":true,"mustEscape":false} -{"type":"attribute","line":3,"col":13,"name":"baz","val":true,"mustEscape":false} -{"type":"end-attributes","line":3,"col":16} -{"type":"newline","line":4,"col":1} -{"type":"tag","line":4,"col":1,"val":"a"} -{"type":"start-attributes","line":4,"col":2} -{"type":"attribute","line":4,"col":3,"name":"foo","val":"'foo, bar, baz'","mustEscape":true} -{"type":"attribute","line":4,"col":24,"name":"bar","val":"1","mustEscape":true} -{"type":"end-attributes","line":4,"col":29} -{"type":"newline","line":5,"col":1} -{"type":"tag","line":5,"col":1,"val":"a"} -{"type":"start-attributes","line":5,"col":2} -{"type":"attribute","line":5,"col":3,"name":"foo","val":"'((foo))'","mustEscape":true} -{"type":"attribute","line":5,"col":18,"name":"bar","val":"(1) ? 1 : 0","mustEscape":true} -{"type":"end-attributes","line":5,"col":35} -{"type":"newline","line":6,"col":1} -{"type":"tag","line":6,"col":1,"val":"select"} -{"type":"indent","line":7,"col":1,"val":2} -{"type":"tag","line":7,"col":3,"val":"option"} -{"type":"start-attributes","line":7,"col":9} -{"type":"attribute","line":7,"col":10,"name":"value","val":"'foo'","mustEscape":true} -{"type":"attribute","line":7,"col":23,"name":"selected","val":true,"mustEscape":false} -{"type":"end-attributes","line":7,"col":31} -{"type":"text","line":7,"col":33,"val":"Foo"} -{"type":"newline","line":8,"col":1} -{"type":"tag","line":8,"col":3,"val":"option"} -{"type":"start-attributes","line":8,"col":9} -{"type":"attribute","line":8,"col":10,"name":"selected","val":true,"mustEscape":true} -{"type":"attribute","line":8,"col":20,"name":"value","val":"'bar'","mustEscape":true} -{"type":"end-attributes","line":8,"col":31} -{"type":"text","line":8,"col":33,"val":"Bar"} -{"type":"outdent","line":9,"col":1} -{"type":"tag","line":9,"col":1,"val":"a"} -{"type":"start-attributes","line":9,"col":2} -{"type":"attribute","line":9,"col":3,"name":"foo","val":"\"class:\"","mustEscape":true} -{"type":"end-attributes","line":9,"col":15} -{"type":"newline","line":10,"col":1} -{"type":"tag","line":10,"col":1,"val":"input"} -{"type":"start-attributes","line":10,"col":6} -{"type":"attribute","line":10,"col":7,"name":"pattern","val":"'\\\\S+'","mustEscape":true} -{"type":"end-attributes","line":10,"col":21} -{"type":"newline","line":12,"col":1} -{"type":"tag","line":12,"col":1,"val":"a"} -{"type":"start-attributes","line":12,"col":2} -{"type":"attribute","line":12,"col":3,"name":"href","val":"'/contact'","mustEscape":true} -{"type":"end-attributes","line":12,"col":18} -{"type":"text","line":12,"col":20,"val":"contact"} -{"type":"newline","line":13,"col":1} -{"type":"tag","line":13,"col":1,"val":"a"} -{"type":"start-attributes","line":13,"col":2} -{"type":"attribute","line":13,"col":3,"name":"href","val":"'/save'","mustEscape":true} -{"type":"end-attributes","line":13,"col":15} -{"type":"class","line":13,"col":16,"val":"button"} -{"type":"text","line":13,"col":24,"val":"save"} -{"type":"newline","line":14,"col":1} -{"type":"tag","line":14,"col":1,"val":"a"} -{"type":"start-attributes","line":14,"col":2} -{"type":"attribute","line":14,"col":3,"name":"foo","val":true,"mustEscape":true} -{"type":"attribute","line":14,"col":7,"name":"bar","val":true,"mustEscape":false} -{"type":"attribute","line":14,"col":11,"name":"baz","val":true,"mustEscape":false} -{"type":"end-attributes","line":14,"col":14} -{"type":"newline","line":15,"col":1} -{"type":"tag","line":15,"col":1,"val":"a"} -{"type":"start-attributes","line":15,"col":2} -{"type":"attribute","line":15,"col":3,"name":"foo","val":"'foo, bar, baz'","mustEscape":true} -{"type":"attribute","line":15,"col":23,"name":"bar","val":"1","mustEscape":true} -{"type":"end-attributes","line":15,"col":28} -{"type":"newline","line":16,"col":1} -{"type":"tag","line":16,"col":1,"val":"a"} -{"type":"start-attributes","line":16,"col":2} -{"type":"attribute","line":16,"col":3,"name":"foo","val":"'((foo))'","mustEscape":true} -{"type":"attribute","line":16,"col":17,"name":"bar","val":"(1) ? 1 : 0","mustEscape":true} -{"type":"end-attributes","line":16,"col":34} -{"type":"newline","line":17,"col":1} -{"type":"tag","line":17,"col":1,"val":"select"} -{"type":"indent","line":18,"col":1,"val":2} -{"type":"tag","line":18,"col":3,"val":"option"} -{"type":"start-attributes","line":18,"col":9} -{"type":"attribute","line":18,"col":10,"name":"value","val":"'foo'","mustEscape":true} -{"type":"attribute","line":18,"col":22,"name":"selected","val":true,"mustEscape":false} -{"type":"end-attributes","line":18,"col":30} -{"type":"text","line":18,"col":32,"val":"Foo"} -{"type":"newline","line":19,"col":1} -{"type":"tag","line":19,"col":3,"val":"option"} -{"type":"start-attributes","line":19,"col":9} -{"type":"attribute","line":19,"col":10,"name":"selected","val":true,"mustEscape":true} -{"type":"attribute","line":19,"col":19,"name":"value","val":"'bar'","mustEscape":true} -{"type":"end-attributes","line":19,"col":30} -{"type":"text","line":19,"col":32,"val":"Bar"} -{"type":"outdent","line":20,"col":1} -{"type":"tag","line":20,"col":1,"val":"a"} -{"type":"start-attributes","line":20,"col":2} -{"type":"attribute","line":20,"col":3,"name":"foo","val":"\"class:\"","mustEscape":true} -{"type":"end-attributes","line":20,"col":15} -{"type":"newline","line":21,"col":1} -{"type":"tag","line":21,"col":1,"val":"input"} -{"type":"start-attributes","line":21,"col":6} -{"type":"attribute","line":21,"col":7,"name":"pattern","val":"'\\\\S+'","mustEscape":true} -{"type":"end-attributes","line":21,"col":21} -{"type":"newline","line":22,"col":1} -{"type":"tag","line":22,"col":1,"val":"foo"} -{"type":"start-attributes","line":22,"col":4} -{"type":"attribute","line":22,"col":5,"name":"terse","val":"\"true\"","mustEscape":true} -{"type":"end-attributes","line":22,"col":17} -{"type":"newline","line":23,"col":1} -{"type":"tag","line":23,"col":1,"val":"foo"} -{"type":"start-attributes","line":23,"col":4} -{"type":"attribute","line":23,"col":5,"name":"date","val":"new Date(0)","mustEscape":true} -{"type":"end-attributes","line":23,"col":21} -{"type":"newline","line":25,"col":1} -{"type":"tag","line":25,"col":1,"val":"foo"} -{"type":"start-attributes","line":25,"col":4} -{"type":"attribute","line":25,"col":5,"name":"abc","val":true,"mustEscape":true} -{"type":"attribute","line":26,"col":5,"name":"def","val":true,"mustEscape":false} -{"type":"end-attributes","line":26,"col":8} -{"type":"newline","line":27,"col":1} -{"type":"tag","line":27,"col":1,"val":"foo"} -{"type":"start-attributes","line":27,"col":4} -{"type":"attribute","line":27,"col":5,"name":"abc","val":true,"mustEscape":true} -{"type":"attribute","line":28,"col":5,"name":"def","val":true,"mustEscape":false} -{"type":"end-attributes","line":28,"col":8} -{"type":"newline","line":29,"col":1} -{"type":"tag","line":29,"col":1,"val":"foo"} -{"type":"start-attributes","line":29,"col":4} -{"type":"attribute","line":29,"col":5,"name":"abc","val":true,"mustEscape":true} -{"type":"attribute","line":30,"col":3,"name":"def","val":true,"mustEscape":false} -{"type":"end-attributes","line":30,"col":6} -{"type":"newline","line":31,"col":1} -{"type":"tag","line":31,"col":1,"val":"foo"} -{"type":"start-attributes","line":31,"col":4} -{"type":"attribute","line":31,"col":5,"name":"abc","val":true,"mustEscape":true} -{"type":"attribute","line":32,"col":4,"name":"def","val":true,"mustEscape":false} -{"type":"end-attributes","line":32,"col":7} -{"type":"newline","line":33,"col":1} -{"type":"tag","line":33,"col":1,"val":"foo"} -{"type":"start-attributes","line":33,"col":4} -{"type":"attribute","line":33,"col":5,"name":"abc","val":true,"mustEscape":true} -{"type":"attribute","line":34,"col":3,"name":"def","val":true,"mustEscape":false} -{"type":"end-attributes","line":34,"col":6} -{"type":"newline","line":35,"col":1} -{"type":"tag","line":35,"col":1,"val":"foo"} -{"type":"start-attributes","line":35,"col":4} -{"type":"attribute","line":35,"col":5,"name":"abc","val":true,"mustEscape":true} -{"type":"attribute","line":36,"col":5,"name":"def","val":true,"mustEscape":false} -{"type":"end-attributes","line":36,"col":8} -{"type":"newline","line":38,"col":1} -{"type":"code","line":38,"col":1,"val":"var attrs = {foo: 'bar', bar: ''}","mustEscape":false,"buffer":false} -{"type":"newline","line":40,"col":1} -{"type":"tag","line":40,"col":1,"val":"div"} -{"type":"&attributes","line":40,"col":4,"val":"attrs"} -{"type":"newline","line":42,"col":1} -{"type":"tag","line":42,"col":1,"val":"a"} -{"type":"start-attributes","line":42,"col":2} -{"type":"attribute","line":42,"col":3,"name":"foo","val":"'foo'","mustEscape":true} -{"type":"attribute","line":42,"col":14,"name":"bar","val":"\"bar\"","mustEscape":true} -{"type":"end-attributes","line":42,"col":24} -{"type":"newline","line":43,"col":1} -{"type":"tag","line":43,"col":1,"val":"a"} -{"type":"start-attributes","line":43,"col":2} -{"type":"attribute","line":43,"col":3,"name":"foo","val":"'foo'","mustEscape":true} -{"type":"attribute","line":43,"col":14,"name":"bar","val":"'bar'","mustEscape":true} -{"type":"end-attributes","line":43,"col":24} -{"type":"newline","line":44,"col":1} -{"type":"eos","line":44,"col":1} \ No newline at end of file +{"type":"tag","loc":{"start":{"line":1,"column":1},"filename":"/cases/attrs.pug","end":{"line":1,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":1,"column":2},"filename":"/cases/attrs.pug","end":{"line":1,"column":3}}} +{"type":"attribute","loc":{"start":{"line":1,"column":3},"filename":"/cases/attrs.pug","end":{"line":1,"column":18}},"name":"href","mustEscape":true,"val":"'/contact'"} +{"type":"end-attributes","loc":{"start":{"line":1,"column":18},"filename":"/cases/attrs.pug","end":{"line":1,"column":19}}} +{"type":"text","loc":{"start":{"line":1,"column":20},"filename":"/cases/attrs.pug","end":{"line":1,"column":27}},"val":"contact"} +{"type":"newline","loc":{"start":{"line":2,"column":1},"filename":"/cases/attrs.pug","end":{"line":2,"column":1}}} +{"type":"tag","loc":{"start":{"line":2,"column":1},"filename":"/cases/attrs.pug","end":{"line":2,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":2,"column":2},"filename":"/cases/attrs.pug","end":{"line":2,"column":3}}} +{"type":"attribute","loc":{"start":{"line":2,"column":3},"filename":"/cases/attrs.pug","end":{"line":2,"column":15}},"name":"href","mustEscape":true,"val":"'/save'"} +{"type":"end-attributes","loc":{"start":{"line":2,"column":15},"filename":"/cases/attrs.pug","end":{"line":2,"column":16}}} +{"type":"class","loc":{"start":{"line":2,"column":16},"filename":"/cases/attrs.pug","end":{"line":2,"column":23}},"val":"button"} +{"type":"text","loc":{"start":{"line":2,"column":24},"filename":"/cases/attrs.pug","end":{"line":2,"column":28}},"val":"save"} +{"type":"newline","loc":{"start":{"line":3,"column":1},"filename":"/cases/attrs.pug","end":{"line":3,"column":1}}} +{"type":"tag","loc":{"start":{"line":3,"column":1},"filename":"/cases/attrs.pug","end":{"line":3,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":3,"column":2},"filename":"/cases/attrs.pug","end":{"line":3,"column":3}}} +{"type":"attribute","loc":{"start":{"line":3,"column":3},"filename":"/cases/attrs.pug","end":{"line":3,"column":6}},"name":"foo","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":3,"column":8},"filename":"/cases/attrs.pug","end":{"line":3,"column":11}},"name":"bar","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":3,"column":13},"filename":"/cases/attrs.pug","end":{"line":3,"column":16}},"name":"baz","mustEscape":true,"val":true} +{"type":"end-attributes","loc":{"start":{"line":3,"column":16},"filename":"/cases/attrs.pug","end":{"line":3,"column":17}}} +{"type":"newline","loc":{"start":{"line":4,"column":1},"filename":"/cases/attrs.pug","end":{"line":4,"column":1}}} +{"type":"tag","loc":{"start":{"line":4,"column":1},"filename":"/cases/attrs.pug","end":{"line":4,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":4,"column":2},"filename":"/cases/attrs.pug","end":{"line":4,"column":3}}} +{"type":"attribute","loc":{"start":{"line":4,"column":3},"filename":"/cases/attrs.pug","end":{"line":4,"column":22}},"name":"foo","mustEscape":true,"val":"'foo, bar, baz'"} +{"type":"attribute","loc":{"start":{"line":4,"column":24},"filename":"/cases/attrs.pug","end":{"line":4,"column":29}},"name":"bar","mustEscape":true,"val":"1"} +{"type":"end-attributes","loc":{"start":{"line":4,"column":29},"filename":"/cases/attrs.pug","end":{"line":4,"column":30}}} +{"type":"newline","loc":{"start":{"line":5,"column":1},"filename":"/cases/attrs.pug","end":{"line":5,"column":1}}} +{"type":"tag","loc":{"start":{"line":5,"column":1},"filename":"/cases/attrs.pug","end":{"line":5,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":5,"column":2},"filename":"/cases/attrs.pug","end":{"line":5,"column":3}}} +{"type":"attribute","loc":{"start":{"line":5,"column":3},"filename":"/cases/attrs.pug","end":{"line":5,"column":16}},"name":"foo","mustEscape":true,"val":"'((foo))'"} +{"type":"attribute","loc":{"start":{"line":5,"column":18},"filename":"/cases/attrs.pug","end":{"line":5,"column":34}},"name":"bar","mustEscape":true,"val":"(1) ? 1 : 0"} +{"type":"end-attributes","loc":{"start":{"line":5,"column":35},"filename":"/cases/attrs.pug","end":{"line":5,"column":36}}} +{"type":"newline","loc":{"start":{"line":6,"column":1},"filename":"/cases/attrs.pug","end":{"line":6,"column":1}}} +{"type":"tag","loc":{"start":{"line":6,"column":1},"filename":"/cases/attrs.pug","end":{"line":6,"column":7}},"val":"select"} +{"type":"indent","loc":{"start":{"line":7,"column":1},"filename":"/cases/attrs.pug","end":{"line":7,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":7,"column":3},"filename":"/cases/attrs.pug","end":{"line":7,"column":9}},"val":"option"} +{"type":"start-attributes","loc":{"start":{"line":7,"column":9},"filename":"/cases/attrs.pug","end":{"line":7,"column":10}}} +{"type":"attribute","loc":{"start":{"line":7,"column":10},"filename":"/cases/attrs.pug","end":{"line":7,"column":21}},"name":"value","mustEscape":true,"val":"'foo'"} +{"type":"attribute","loc":{"start":{"line":7,"column":23},"filename":"/cases/attrs.pug","end":{"line":7,"column":31}},"name":"selected","mustEscape":true,"val":true} +{"type":"end-attributes","loc":{"start":{"line":7,"column":31},"filename":"/cases/attrs.pug","end":{"line":7,"column":32}}} +{"type":"text","loc":{"start":{"line":7,"column":33},"filename":"/cases/attrs.pug","end":{"line":7,"column":36}},"val":"Foo"} +{"type":"newline","loc":{"start":{"line":8,"column":1},"filename":"/cases/attrs.pug","end":{"line":8,"column":3}}} +{"type":"tag","loc":{"start":{"line":8,"column":3},"filename":"/cases/attrs.pug","end":{"line":8,"column":9}},"val":"option"} +{"type":"start-attributes","loc":{"start":{"line":8,"column":9},"filename":"/cases/attrs.pug","end":{"line":8,"column":10}}} +{"type":"attribute","loc":{"start":{"line":8,"column":10},"filename":"/cases/attrs.pug","end":{"line":8,"column":18}},"name":"selected","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":8,"column":20},"filename":"/cases/attrs.pug","end":{"line":8,"column":31}},"name":"value","mustEscape":true,"val":"'bar'"} +{"type":"end-attributes","loc":{"start":{"line":8,"column":31},"filename":"/cases/attrs.pug","end":{"line":8,"column":32}}} +{"type":"text","loc":{"start":{"line":8,"column":33},"filename":"/cases/attrs.pug","end":{"line":8,"column":36}},"val":"Bar"} +{"type":"outdent","loc":{"start":{"line":9,"column":1},"filename":"/cases/attrs.pug","end":{"line":9,"column":1}}} +{"type":"tag","loc":{"start":{"line":9,"column":1},"filename":"/cases/attrs.pug","end":{"line":9,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":9,"column":2},"filename":"/cases/attrs.pug","end":{"line":9,"column":3}}} +{"type":"attribute","loc":{"start":{"line":9,"column":3},"filename":"/cases/attrs.pug","end":{"line":9,"column":15}},"name":"foo","mustEscape":true,"val":"\"class:\""} +{"type":"end-attributes","loc":{"start":{"line":9,"column":15},"filename":"/cases/attrs.pug","end":{"line":9,"column":16}}} +{"type":"newline","loc":{"start":{"line":10,"column":1},"filename":"/cases/attrs.pug","end":{"line":10,"column":1}}} +{"type":"tag","loc":{"start":{"line":10,"column":1},"filename":"/cases/attrs.pug","end":{"line":10,"column":6}},"val":"input"} +{"type":"start-attributes","loc":{"start":{"line":10,"column":6},"filename":"/cases/attrs.pug","end":{"line":10,"column":7}}} +{"type":"attribute","loc":{"start":{"line":10,"column":7},"filename":"/cases/attrs.pug","end":{"line":10,"column":21}},"name":"pattern","mustEscape":true,"val":"'\\\\S+'"} +{"type":"end-attributes","loc":{"start":{"line":10,"column":21},"filename":"/cases/attrs.pug","end":{"line":10,"column":22}}} +{"type":"newline","loc":{"start":{"line":12,"column":1},"filename":"/cases/attrs.pug","end":{"line":12,"column":1}}} +{"type":"tag","loc":{"start":{"line":12,"column":1},"filename":"/cases/attrs.pug","end":{"line":12,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":12,"column":2},"filename":"/cases/attrs.pug","end":{"line":12,"column":3}}} +{"type":"attribute","loc":{"start":{"line":12,"column":3},"filename":"/cases/attrs.pug","end":{"line":12,"column":18}},"name":"href","mustEscape":true,"val":"'/contact'"} +{"type":"end-attributes","loc":{"start":{"line":12,"column":18},"filename":"/cases/attrs.pug","end":{"line":12,"column":19}}} +{"type":"text","loc":{"start":{"line":12,"column":20},"filename":"/cases/attrs.pug","end":{"line":12,"column":27}},"val":"contact"} +{"type":"newline","loc":{"start":{"line":13,"column":1},"filename":"/cases/attrs.pug","end":{"line":13,"column":1}}} +{"type":"tag","loc":{"start":{"line":13,"column":1},"filename":"/cases/attrs.pug","end":{"line":13,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":13,"column":2},"filename":"/cases/attrs.pug","end":{"line":13,"column":3}}} +{"type":"attribute","loc":{"start":{"line":13,"column":3},"filename":"/cases/attrs.pug","end":{"line":13,"column":15}},"name":"href","mustEscape":true,"val":"'/save'"} +{"type":"end-attributes","loc":{"start":{"line":13,"column":15},"filename":"/cases/attrs.pug","end":{"line":13,"column":16}}} +{"type":"class","loc":{"start":{"line":13,"column":16},"filename":"/cases/attrs.pug","end":{"line":13,"column":23}},"val":"button"} +{"type":"text","loc":{"start":{"line":13,"column":24},"filename":"/cases/attrs.pug","end":{"line":13,"column":28}},"val":"save"} +{"type":"newline","loc":{"start":{"line":14,"column":1},"filename":"/cases/attrs.pug","end":{"line":14,"column":1}}} +{"type":"tag","loc":{"start":{"line":14,"column":1},"filename":"/cases/attrs.pug","end":{"line":14,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":14,"column":2},"filename":"/cases/attrs.pug","end":{"line":14,"column":3}}} +{"type":"attribute","loc":{"start":{"line":14,"column":3},"filename":"/cases/attrs.pug","end":{"line":14,"column":6}},"name":"foo","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":14,"column":7},"filename":"/cases/attrs.pug","end":{"line":14,"column":10}},"name":"bar","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":14,"column":11},"filename":"/cases/attrs.pug","end":{"line":14,"column":14}},"name":"baz","mustEscape":true,"val":true} +{"type":"end-attributes","loc":{"start":{"line":14,"column":14},"filename":"/cases/attrs.pug","end":{"line":14,"column":15}}} +{"type":"newline","loc":{"start":{"line":15,"column":1},"filename":"/cases/attrs.pug","end":{"line":15,"column":1}}} +{"type":"tag","loc":{"start":{"line":15,"column":1},"filename":"/cases/attrs.pug","end":{"line":15,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":15,"column":2},"filename":"/cases/attrs.pug","end":{"line":15,"column":3}}} +{"type":"attribute","loc":{"start":{"line":15,"column":3},"filename":"/cases/attrs.pug","end":{"line":15,"column":22}},"name":"foo","mustEscape":true,"val":"'foo, bar, baz'"} +{"type":"attribute","loc":{"start":{"line":15,"column":23},"filename":"/cases/attrs.pug","end":{"line":15,"column":28}},"name":"bar","mustEscape":true,"val":"1"} +{"type":"end-attributes","loc":{"start":{"line":15,"column":28},"filename":"/cases/attrs.pug","end":{"line":15,"column":29}}} +{"type":"newline","loc":{"start":{"line":16,"column":1},"filename":"/cases/attrs.pug","end":{"line":16,"column":1}}} +{"type":"tag","loc":{"start":{"line":16,"column":1},"filename":"/cases/attrs.pug","end":{"line":16,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":16,"column":2},"filename":"/cases/attrs.pug","end":{"line":16,"column":3}}} +{"type":"attribute","loc":{"start":{"line":16,"column":3},"filename":"/cases/attrs.pug","end":{"line":16,"column":16}},"name":"foo","mustEscape":true,"val":"'((foo))'"} +{"type":"attribute","loc":{"start":{"line":16,"column":17},"filename":"/cases/attrs.pug","end":{"line":16,"column":33}},"name":"bar","mustEscape":true,"val":"(1) ? 1 : 0"} +{"type":"end-attributes","loc":{"start":{"line":16,"column":34},"filename":"/cases/attrs.pug","end":{"line":16,"column":35}}} +{"type":"newline","loc":{"start":{"line":17,"column":1},"filename":"/cases/attrs.pug","end":{"line":17,"column":1}}} +{"type":"tag","loc":{"start":{"line":17,"column":1},"filename":"/cases/attrs.pug","end":{"line":17,"column":7}},"val":"select"} +{"type":"indent","loc":{"start":{"line":18,"column":1},"filename":"/cases/attrs.pug","end":{"line":18,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":18,"column":3},"filename":"/cases/attrs.pug","end":{"line":18,"column":9}},"val":"option"} +{"type":"start-attributes","loc":{"start":{"line":18,"column":9},"filename":"/cases/attrs.pug","end":{"line":18,"column":10}}} +{"type":"attribute","loc":{"start":{"line":18,"column":10},"filename":"/cases/attrs.pug","end":{"line":18,"column":21}},"name":"value","mustEscape":true,"val":"'foo'"} +{"type":"attribute","loc":{"start":{"line":18,"column":22},"filename":"/cases/attrs.pug","end":{"line":18,"column":30}},"name":"selected","mustEscape":true,"val":true} +{"type":"end-attributes","loc":{"start":{"line":18,"column":30},"filename":"/cases/attrs.pug","end":{"line":18,"column":31}}} +{"type":"text","loc":{"start":{"line":18,"column":32},"filename":"/cases/attrs.pug","end":{"line":18,"column":35}},"val":"Foo"} +{"type":"newline","loc":{"start":{"line":19,"column":1},"filename":"/cases/attrs.pug","end":{"line":19,"column":3}}} +{"type":"tag","loc":{"start":{"line":19,"column":3},"filename":"/cases/attrs.pug","end":{"line":19,"column":9}},"val":"option"} +{"type":"start-attributes","loc":{"start":{"line":19,"column":9},"filename":"/cases/attrs.pug","end":{"line":19,"column":10}}} +{"type":"attribute","loc":{"start":{"line":19,"column":10},"filename":"/cases/attrs.pug","end":{"line":19,"column":18}},"name":"selected","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":19,"column":19},"filename":"/cases/attrs.pug","end":{"line":19,"column":30}},"name":"value","mustEscape":true,"val":"'bar'"} +{"type":"end-attributes","loc":{"start":{"line":19,"column":30},"filename":"/cases/attrs.pug","end":{"line":19,"column":31}}} +{"type":"text","loc":{"start":{"line":19,"column":32},"filename":"/cases/attrs.pug","end":{"line":19,"column":35}},"val":"Bar"} +{"type":"outdent","loc":{"start":{"line":20,"column":1},"filename":"/cases/attrs.pug","end":{"line":20,"column":1}}} +{"type":"tag","loc":{"start":{"line":20,"column":1},"filename":"/cases/attrs.pug","end":{"line":20,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":20,"column":2},"filename":"/cases/attrs.pug","end":{"line":20,"column":3}}} +{"type":"attribute","loc":{"start":{"line":20,"column":3},"filename":"/cases/attrs.pug","end":{"line":20,"column":15}},"name":"foo","mustEscape":true,"val":"\"class:\""} +{"type":"end-attributes","loc":{"start":{"line":20,"column":15},"filename":"/cases/attrs.pug","end":{"line":20,"column":16}}} +{"type":"newline","loc":{"start":{"line":21,"column":1},"filename":"/cases/attrs.pug","end":{"line":21,"column":1}}} +{"type":"tag","loc":{"start":{"line":21,"column":1},"filename":"/cases/attrs.pug","end":{"line":21,"column":6}},"val":"input"} +{"type":"start-attributes","loc":{"start":{"line":21,"column":6},"filename":"/cases/attrs.pug","end":{"line":21,"column":7}}} +{"type":"attribute","loc":{"start":{"line":21,"column":7},"filename":"/cases/attrs.pug","end":{"line":21,"column":21}},"name":"pattern","mustEscape":true,"val":"'\\\\S+'"} +{"type":"end-attributes","loc":{"start":{"line":21,"column":21},"filename":"/cases/attrs.pug","end":{"line":21,"column":22}}} +{"type":"newline","loc":{"start":{"line":22,"column":1},"filename":"/cases/attrs.pug","end":{"line":22,"column":1}}} +{"type":"tag","loc":{"start":{"line":22,"column":1},"filename":"/cases/attrs.pug","end":{"line":22,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":22,"column":4},"filename":"/cases/attrs.pug","end":{"line":22,"column":5}}} +{"type":"attribute","loc":{"start":{"line":22,"column":5},"filename":"/cases/attrs.pug","end":{"line":22,"column":17}},"name":"terse","mustEscape":true,"val":"\"true\""} +{"type":"end-attributes","loc":{"start":{"line":22,"column":17},"filename":"/cases/attrs.pug","end":{"line":22,"column":18}}} +{"type":"newline","loc":{"start":{"line":23,"column":1},"filename":"/cases/attrs.pug","end":{"line":23,"column":1}}} +{"type":"tag","loc":{"start":{"line":23,"column":1},"filename":"/cases/attrs.pug","end":{"line":23,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":23,"column":4},"filename":"/cases/attrs.pug","end":{"line":23,"column":5}}} +{"type":"attribute","loc":{"start":{"line":23,"column":5},"filename":"/cases/attrs.pug","end":{"line":23,"column":21}},"name":"date","mustEscape":true,"val":"new Date(0)"} +{"type":"end-attributes","loc":{"start":{"line":23,"column":21},"filename":"/cases/attrs.pug","end":{"line":23,"column":22}}} +{"type":"newline","loc":{"start":{"line":25,"column":1},"filename":"/cases/attrs.pug","end":{"line":25,"column":1}}} +{"type":"tag","loc":{"start":{"line":25,"column":1},"filename":"/cases/attrs.pug","end":{"line":25,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":25,"column":4},"filename":"/cases/attrs.pug","end":{"line":25,"column":5}}} +{"type":"attribute","loc":{"start":{"line":25,"column":5},"filename":"/cases/attrs.pug","end":{"line":25,"column":8}},"name":"abc","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":26,"column":5},"filename":"/cases/attrs.pug","end":{"line":26,"column":8}},"name":"def","mustEscape":true,"val":true} +{"type":"end-attributes","loc":{"start":{"line":26,"column":8},"filename":"/cases/attrs.pug","end":{"line":26,"column":9}}} +{"type":"newline","loc":{"start":{"line":27,"column":1},"filename":"/cases/attrs.pug","end":{"line":27,"column":1}}} +{"type":"tag","loc":{"start":{"line":27,"column":1},"filename":"/cases/attrs.pug","end":{"line":27,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":27,"column":4},"filename":"/cases/attrs.pug","end":{"line":27,"column":5}}} +{"type":"attribute","loc":{"start":{"line":27,"column":5},"filename":"/cases/attrs.pug","end":{"line":27,"column":8}},"name":"abc","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":28,"column":5},"filename":"/cases/attrs.pug","end":{"line":28,"column":8}},"name":"def","mustEscape":true,"val":true} +{"type":"end-attributes","loc":{"start":{"line":28,"column":8},"filename":"/cases/attrs.pug","end":{"line":28,"column":9}}} +{"type":"newline","loc":{"start":{"line":29,"column":1},"filename":"/cases/attrs.pug","end":{"line":29,"column":1}}} +{"type":"tag","loc":{"start":{"line":29,"column":1},"filename":"/cases/attrs.pug","end":{"line":29,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":29,"column":4},"filename":"/cases/attrs.pug","end":{"line":29,"column":5}}} +{"type":"attribute","loc":{"start":{"line":29,"column":5},"filename":"/cases/attrs.pug","end":{"line":29,"column":8}},"name":"abc","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":30,"column":3},"filename":"/cases/attrs.pug","end":{"line":30,"column":6}},"name":"def","mustEscape":true,"val":true} +{"type":"end-attributes","loc":{"start":{"line":30,"column":6},"filename":"/cases/attrs.pug","end":{"line":30,"column":7}}} +{"type":"newline","loc":{"start":{"line":31,"column":1},"filename":"/cases/attrs.pug","end":{"line":31,"column":1}}} +{"type":"tag","loc":{"start":{"line":31,"column":1},"filename":"/cases/attrs.pug","end":{"line":31,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":31,"column":4},"filename":"/cases/attrs.pug","end":{"line":31,"column":5}}} +{"type":"attribute","loc":{"start":{"line":31,"column":5},"filename":"/cases/attrs.pug","end":{"line":31,"column":8}},"name":"abc","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":32,"column":4},"filename":"/cases/attrs.pug","end":{"line":32,"column":7}},"name":"def","mustEscape":true,"val":true} +{"type":"end-attributes","loc":{"start":{"line":32,"column":7},"filename":"/cases/attrs.pug","end":{"line":32,"column":8}}} +{"type":"newline","loc":{"start":{"line":33,"column":1},"filename":"/cases/attrs.pug","end":{"line":33,"column":1}}} +{"type":"tag","loc":{"start":{"line":33,"column":1},"filename":"/cases/attrs.pug","end":{"line":33,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":33,"column":4},"filename":"/cases/attrs.pug","end":{"line":33,"column":5}}} +{"type":"attribute","loc":{"start":{"line":33,"column":5},"filename":"/cases/attrs.pug","end":{"line":33,"column":8}},"name":"abc","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":34,"column":3},"filename":"/cases/attrs.pug","end":{"line":34,"column":6}},"name":"def","mustEscape":true,"val":true} +{"type":"end-attributes","loc":{"start":{"line":34,"column":6},"filename":"/cases/attrs.pug","end":{"line":34,"column":7}}} +{"type":"newline","loc":{"start":{"line":35,"column":1},"filename":"/cases/attrs.pug","end":{"line":35,"column":1}}} +{"type":"tag","loc":{"start":{"line":35,"column":1},"filename":"/cases/attrs.pug","end":{"line":35,"column":4}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":35,"column":4},"filename":"/cases/attrs.pug","end":{"line":35,"column":5}}} +{"type":"attribute","loc":{"start":{"line":35,"column":5},"filename":"/cases/attrs.pug","end":{"line":35,"column":8}},"name":"abc","mustEscape":true,"val":true} +{"type":"attribute","loc":{"start":{"line":36,"column":5},"filename":"/cases/attrs.pug","end":{"line":36,"column":8}},"name":"def","mustEscape":true,"val":true} +{"type":"end-attributes","loc":{"start":{"line":36,"column":8},"filename":"/cases/attrs.pug","end":{"line":36,"column":9}}} +{"type":"newline","loc":{"start":{"line":38,"column":1},"filename":"/cases/attrs.pug","end":{"line":38,"column":1}}} +{"type":"code","loc":{"start":{"line":38,"column":1},"filename":"/cases/attrs.pug","end":{"line":38,"column":41}},"val":"var attrs = {foo: 'bar', bar: ''}","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":40,"column":1},"filename":"/cases/attrs.pug","end":{"line":40,"column":1}}} +{"type":"tag","loc":{"start":{"line":40,"column":1},"filename":"/cases/attrs.pug","end":{"line":40,"column":4}},"val":"div"} +{"type":"&attributes","loc":{"start":{"line":40,"column":4},"filename":"/cases/attrs.pug","end":{"line":40,"column":22}},"val":"attrs"} +{"type":"newline","loc":{"start":{"line":42,"column":1},"filename":"/cases/attrs.pug","end":{"line":42,"column":1}}} +{"type":"tag","loc":{"start":{"line":42,"column":1},"filename":"/cases/attrs.pug","end":{"line":42,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":42,"column":2},"filename":"/cases/attrs.pug","end":{"line":42,"column":3}}} +{"type":"attribute","loc":{"start":{"line":42,"column":3},"filename":"/cases/attrs.pug","end":{"line":42,"column":12}},"name":"foo","mustEscape":true,"val":"'foo'"} +{"type":"attribute","loc":{"start":{"line":42,"column":13},"filename":"/cases/attrs.pug","end":{"line":42,"column":24}},"name":"bar","mustEscape":true,"val":"\"bar\""} +{"type":"end-attributes","loc":{"start":{"line":42,"column":24},"filename":"/cases/attrs.pug","end":{"line":42,"column":25}}} +{"type":"newline","loc":{"start":{"line":43,"column":1},"filename":"/cases/attrs.pug","end":{"line":43,"column":1}}} +{"type":"tag","loc":{"start":{"line":43,"column":1},"filename":"/cases/attrs.pug","end":{"line":43,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":43,"column":2},"filename":"/cases/attrs.pug","end":{"line":43,"column":3}}} +{"type":"attribute","loc":{"start":{"line":43,"column":3},"filename":"/cases/attrs.pug","end":{"line":43,"column":12}},"name":"foo","mustEscape":true,"val":"'foo'"} +{"type":"attribute","loc":{"start":{"line":43,"column":13},"filename":"/cases/attrs.pug","end":{"line":43,"column":24}},"name":"bar","mustEscape":true,"val":"'bar'"} +{"type":"end-attributes","loc":{"start":{"line":43,"column":24},"filename":"/cases/attrs.pug","end":{"line":43,"column":25}}} +{"type":"newline","loc":{"start":{"line":44,"column":1},"filename":"/cases/attrs.pug","end":{"line":44,"column":1}}} +{"type":"eos","loc":{"start":{"line":44,"column":1},"filename":"/cases/attrs.pug","end":{"line":44,"column":1}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/attrs.unescaped.tokens.json b/packages/pug-parser/test/cases/attrs.unescaped.tokens.json index bc7d33633..9cce52196 100644 --- a/packages/pug-parser/test/cases/attrs.unescaped.tokens.json +++ b/packages/pug-parser/test/cases/attrs.unescaped.tokens.json @@ -1,15 +1,15 @@ -{"type":"tag","line":1,"col":1,"val":"script"} -{"type":"start-attributes","line":1,"col":7} -{"type":"attribute","line":1,"col":8,"name":"type","val":"'text/x-template'","mustEscape":true} -{"type":"end-attributes","line":1,"col":30} -{"type":"indent","line":2,"col":1,"val":2} -{"type":"tag","line":2,"col":3,"val":"div"} -{"type":"start-attributes","line":2,"col":6} -{"type":"attribute","line":2,"col":7,"name":"id","val":"'user-<%= user.id %>'","mustEscape":false} -{"type":"end-attributes","line":2,"col":32} -{"type":"indent","line":3,"col":1,"val":4} -{"type":"tag","line":3,"col":5,"val":"h1"} -{"type":"text","line":3,"col":8,"val":"<%= user.title %>"} -{"type":"outdent","line":3,"col":25} -{"type":"outdent","line":3,"col":25} -{"type":"eos","line":3,"col":25} \ No newline at end of file +{"type":"tag","loc":{"start":{"line":1,"column":1},"filename":"/cases/attrs.unescaped.pug","end":{"line":1,"column":7}},"val":"script"} +{"type":"start-attributes","loc":{"start":{"line":1,"column":7},"filename":"/cases/attrs.unescaped.pug","end":{"line":1,"column":8}}} +{"type":"attribute","loc":{"start":{"line":1,"column":8},"filename":"/cases/attrs.unescaped.pug","end":{"line":1,"column":30}},"name":"type","mustEscape":true,"val":"'text/x-template'"} +{"type":"end-attributes","loc":{"start":{"line":1,"column":30},"filename":"/cases/attrs.unescaped.pug","end":{"line":1,"column":31}}} +{"type":"indent","loc":{"start":{"line":2,"column":1},"filename":"/cases/attrs.unescaped.pug","end":{"line":2,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":2,"column":3},"filename":"/cases/attrs.unescaped.pug","end":{"line":2,"column":6}},"val":"div"} +{"type":"start-attributes","loc":{"start":{"line":2,"column":6},"filename":"/cases/attrs.unescaped.pug","end":{"line":2,"column":7}}} +{"type":"attribute","loc":{"start":{"line":2,"column":7},"filename":"/cases/attrs.unescaped.pug","end":{"line":2,"column":32}},"name":"id","mustEscape":false,"val":"'user-<%= user.id %>'"} +{"type":"end-attributes","loc":{"start":{"line":2,"column":32},"filename":"/cases/attrs.unescaped.pug","end":{"line":2,"column":33}}} +{"type":"indent","loc":{"start":{"line":3,"column":1},"filename":"/cases/attrs.unescaped.pug","end":{"line":3,"column":5}},"val":4} +{"type":"tag","loc":{"start":{"line":3,"column":5},"filename":"/cases/attrs.unescaped.pug","end":{"line":3,"column":7}},"val":"h1"} +{"type":"text","loc":{"start":{"line":3,"column":8},"filename":"/cases/attrs.unescaped.pug","end":{"line":3,"column":25}},"val":"<%= user.title %>"} +{"type":"outdent","loc":{"start":{"line":3,"column":25},"filename":"/cases/attrs.unescaped.pug","end":{"line":3,"column":25}}} +{"type":"outdent","loc":{"start":{"line":3,"column":25},"filename":"/cases/attrs.unescaped.pug","end":{"line":3,"column":25}}} +{"type":"eos","loc":{"start":{"line":3,"column":25},"filename":"/cases/attrs.unescaped.pug","end":{"line":3,"column":25}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/basic.tokens.json b/packages/pug-parser/test/cases/basic.tokens.json index 7897d33f4..0d38aae15 100644 --- a/packages/pug-parser/test/cases/basic.tokens.json +++ b/packages/pug-parser/test/cases/basic.tokens.json @@ -1,9 +1,9 @@ -{"type":"tag","line":1,"col":1,"val":"html"} -{"type":"indent","line":2,"col":1,"val":2} -{"type":"tag","line":2,"col":3,"val":"body"} -{"type":"indent","line":3,"col":1,"val":4} -{"type":"tag","line":3,"col":5,"val":"h1"} -{"type":"text","line":3,"col":8,"val":"Title"} -{"type":"outdent","line":3,"col":13} -{"type":"outdent","line":3,"col":13} -{"type":"eos","line":3,"col":13} \ No newline at end of file +{"type":"tag","loc":{"start":{"line":1,"column":1},"filename":"/cases/basic.pug","end":{"line":1,"column":5}},"val":"html"} +{"type":"indent","loc":{"start":{"line":2,"column":1},"filename":"/cases/basic.pug","end":{"line":2,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":2,"column":3},"filename":"/cases/basic.pug","end":{"line":2,"column":7}},"val":"body"} +{"type":"indent","loc":{"start":{"line":3,"column":1},"filename":"/cases/basic.pug","end":{"line":3,"column":5}},"val":4} +{"type":"tag","loc":{"start":{"line":3,"column":5},"filename":"/cases/basic.pug","end":{"line":3,"column":7}},"val":"h1"} +{"type":"text","loc":{"start":{"line":3,"column":8},"filename":"/cases/basic.pug","end":{"line":3,"column":13}},"val":"Title"} +{"type":"outdent","loc":{"start":{"line":3,"column":13},"filename":"/cases/basic.pug","end":{"line":3,"column":13}}} +{"type":"outdent","loc":{"start":{"line":3,"column":13},"filename":"/cases/basic.pug","end":{"line":3,"column":13}}} +{"type":"eos","loc":{"start":{"line":3,"column":13},"filename":"/cases/basic.pug","end":{"line":3,"column":13}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/blanks.tokens.json b/packages/pug-parser/test/cases/blanks.tokens.json index f20431ab6..1529f5c88 100644 --- a/packages/pug-parser/test/cases/blanks.tokens.json +++ b/packages/pug-parser/test/cases/blanks.tokens.json @@ -1,13 +1,13 @@ -{"type":"newline","line":3,"col":1} -{"type":"tag","line":3,"col":1,"val":"ul"} -{"type":"indent","line":4,"col":1,"val":2} -{"type":"tag","line":4,"col":3,"val":"li"} -{"type":"text","line":4,"col":6,"val":"foo"} -{"type":"newline","line":6,"col":1} -{"type":"tag","line":6,"col":3,"val":"li"} -{"type":"text","line":6,"col":6,"val":"bar"} -{"type":"newline","line":8,"col":1} -{"type":"tag","line":8,"col":3,"val":"li"} -{"type":"text","line":8,"col":6,"val":"baz"} -{"type":"outdent","line":9,"col":1} -{"type":"eos","line":9,"col":1} \ No newline at end of file +{"type":"newline","loc":{"start":{"line":3,"column":1},"filename":"/cases/blanks.pug","end":{"line":3,"column":1}}} +{"type":"tag","loc":{"start":{"line":3,"column":1},"filename":"/cases/blanks.pug","end":{"line":3,"column":3}},"val":"ul"} +{"type":"indent","loc":{"start":{"line":4,"column":1},"filename":"/cases/blanks.pug","end":{"line":4,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":4,"column":3},"filename":"/cases/blanks.pug","end":{"line":4,"column":5}},"val":"li"} +{"type":"text","loc":{"start":{"line":4,"column":6},"filename":"/cases/blanks.pug","end":{"line":4,"column":9}},"val":"foo"} +{"type":"newline","loc":{"start":{"line":6,"column":1},"filename":"/cases/blanks.pug","end":{"line":6,"column":3}}} +{"type":"tag","loc":{"start":{"line":6,"column":3},"filename":"/cases/blanks.pug","end":{"line":6,"column":5}},"val":"li"} +{"type":"text","loc":{"start":{"line":6,"column":6},"filename":"/cases/blanks.pug","end":{"line":6,"column":9}},"val":"bar"} +{"type":"newline","loc":{"start":{"line":8,"column":1},"filename":"/cases/blanks.pug","end":{"line":8,"column":3}}} +{"type":"tag","loc":{"start":{"line":8,"column":3},"filename":"/cases/blanks.pug","end":{"line":8,"column":5}},"val":"li"} +{"type":"text","loc":{"start":{"line":8,"column":6},"filename":"/cases/blanks.pug","end":{"line":8,"column":9}},"val":"baz"} +{"type":"outdent","loc":{"start":{"line":9,"column":1},"filename":"/cases/blanks.pug","end":{"line":9,"column":1}}} +{"type":"eos","loc":{"start":{"line":9,"column":1},"filename":"/cases/blanks.pug","end":{"line":9,"column":1}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/block-code.tokens.json b/packages/pug-parser/test/cases/block-code.tokens.json index b2acbc132..bff169482 100644 --- a/packages/pug-parser/test/cases/block-code.tokens.json +++ b/packages/pug-parser/test/cases/block-code.tokens.json @@ -1,28 +1,28 @@ -{"type":"blockcode","line":1,"col":1} -{"type":"start-pipeless-text","line":1,"col":2} -{"type":"text","line":2,"col":3,"val":"list = [\"uno\", \"dos\", \"tres\","} -{"type":"newline","line":3,"col":1} -{"type":"text","line":3,"col":3,"val":" \"cuatro\", \"cinco\", \"seis\"];"} -{"type":"end-pipeless-text","line":3,"col":38} -{"type":"newline","line":4,"col":1} -{"type":"comment","line":4,"col":1,"val":" Without a block, the element is accepted and no code is generated","buffer":false} -{"type":"newline","line":5,"col":1} -{"type":"blockcode","line":5,"col":1} -{"type":"newline","line":6,"col":1} -{"type":"each","line":6,"col":1,"val":"item","key":null,"code":"list"} -{"type":"indent","line":7,"col":1,"val":2} -{"type":"blockcode","line":7,"col":3} -{"type":"start-pipeless-text","line":7,"col":4} -{"type":"text","line":8,"col":5,"val":"string = item.charAt(0)"} -{"type":"newline","line":9,"col":1} -{"type":"text","line":9,"col":5,"val":""} -{"type":"newline","line":10,"col":1} -{"type":"text","line":10,"col":5,"val":" .toUpperCase() +"} -{"type":"newline","line":11,"col":1} -{"type":"text","line":11,"col":5,"val":"item.slice(1);"} -{"type":"end-pipeless-text","line":11,"col":19} -{"type":"newline","line":12,"col":1} -{"type":"tag","line":12,"col":3,"val":"li"} -{"type":"code","line":12,"col":5,"val":"string","mustEscape":true,"buffer":true} -{"type":"outdent","line":13,"col":1} -{"type":"eos","line":13,"col":1} \ No newline at end of file +{"type":"blockcode","loc":{"start":{"line":1,"column":1},"filename":"/cases/block-code.pug","end":{"line":1,"column":2}}} +{"type":"start-pipeless-text","loc":{"start":{"line":1,"column":2},"filename":"/cases/block-code.pug","end":{"line":1,"column":2}}} +{"type":"text","loc":{"start":{"line":2,"column":3},"filename":"/cases/block-code.pug","end":{"line":2,"column":32}},"val":"list = [\"uno\", \"dos\", \"tres\","} +{"type":"newline","loc":{"start":{"line":3,"column":1},"filename":"/cases/block-code.pug","end":{"line":3,"column":3}}} +{"type":"text","loc":{"start":{"line":3,"column":3},"filename":"/cases/block-code.pug","end":{"line":3,"column":38}},"val":" \"cuatro\", \"cinco\", \"seis\"];"} +{"type":"end-pipeless-text","loc":{"start":{"line":3,"column":38},"filename":"/cases/block-code.pug","end":{"line":3,"column":38}}} +{"type":"newline","loc":{"start":{"line":4,"column":1},"filename":"/cases/block-code.pug","end":{"line":4,"column":1}}} +{"type":"comment","loc":{"start":{"line":4,"column":1},"filename":"/cases/block-code.pug","end":{"line":4,"column":70}},"val":" Without a block, the element is accepted and no code is generated","buffer":false} +{"type":"newline","loc":{"start":{"line":5,"column":1},"filename":"/cases/block-code.pug","end":{"line":5,"column":1}}} +{"type":"blockcode","loc":{"start":{"line":5,"column":1},"filename":"/cases/block-code.pug","end":{"line":5,"column":2}}} +{"type":"newline","loc":{"start":{"line":6,"column":1},"filename":"/cases/block-code.pug","end":{"line":6,"column":1}}} +{"type":"each","loc":{"start":{"line":6,"column":1},"filename":"/cases/block-code.pug","end":{"line":6,"column":18}},"val":"item","key":null,"code":"list"} +{"type":"indent","loc":{"start":{"line":7,"column":1},"filename":"/cases/block-code.pug","end":{"line":7,"column":3}},"val":2} +{"type":"blockcode","loc":{"start":{"line":7,"column":3},"filename":"/cases/block-code.pug","end":{"line":7,"column":4}}} +{"type":"start-pipeless-text","loc":{"start":{"line":7,"column":4},"filename":"/cases/block-code.pug","end":{"line":7,"column":4}}} +{"type":"text","loc":{"start":{"line":8,"column":5},"filename":"/cases/block-code.pug","end":{"line":8,"column":28}},"val":"string = item.charAt(0)"} +{"type":"newline","loc":{"start":{"line":9,"column":1},"filename":"/cases/block-code.pug","end":{"line":9,"column":5}}} +{"type":"text","loc":{"start":{"line":9,"column":5},"filename":"/cases/block-code.pug","end":{"line":9,"column":5}},"val":""} +{"type":"newline","loc":{"start":{"line":10,"column":1},"filename":"/cases/block-code.pug","end":{"line":10,"column":5}}} +{"type":"text","loc":{"start":{"line":10,"column":5},"filename":"/cases/block-code.pug","end":{"line":10,"column":23}},"val":" .toUpperCase() +"} +{"type":"newline","loc":{"start":{"line":11,"column":1},"filename":"/cases/block-code.pug","end":{"line":11,"column":5}}} +{"type":"text","loc":{"start":{"line":11,"column":5},"filename":"/cases/block-code.pug","end":{"line":11,"column":19}},"val":"item.slice(1);"} +{"type":"end-pipeless-text","loc":{"start":{"line":11,"column":19},"filename":"/cases/block-code.pug","end":{"line":11,"column":19}}} +{"type":"newline","loc":{"start":{"line":12,"column":1},"filename":"/cases/block-code.pug","end":{"line":12,"column":3}}} +{"type":"tag","loc":{"start":{"line":12,"column":3},"filename":"/cases/block-code.pug","end":{"line":12,"column":5}},"val":"li"} +{"type":"code","loc":{"start":{"line":12,"column":5},"filename":"/cases/block-code.pug","end":{"line":12,"column":13}},"val":"string","mustEscape":true,"buffer":true} +{"type":"outdent","loc":{"start":{"line":13,"column":1},"filename":"/cases/block-code.pug","end":{"line":13,"column":1}}} +{"type":"eos","loc":{"start":{"line":13,"column":1},"filename":"/cases/block-code.pug","end":{"line":13,"column":1}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/block-expansion.shorthands.tokens.json b/packages/pug-parser/test/cases/block-expansion.shorthands.tokens.json index 24c4ff968..055869e46 100644 --- a/packages/pug-parser/test/cases/block-expansion.shorthands.tokens.json +++ b/packages/pug-parser/test/cases/block-expansion.shorthands.tokens.json @@ -1,11 +1,11 @@ -{"type":"tag","line":1,"col":1,"val":"ul"} -{"type":"indent","line":2,"col":1,"val":2} -{"type":"tag","line":2,"col":3,"val":"li"} -{"type":"class","line":2,"col":5,"val":"list-item"} -{"type":":","line":2,"col":15} -{"type":"class","line":2,"col":17,"val":"foo"} -{"type":":","line":2,"col":21} -{"type":"id","line":2,"col":23,"val":"bar"} -{"type":"text","line":2,"col":28,"val":"baz"} -{"type":"outdent","line":2,"col":31} -{"type":"eos","line":2,"col":31} \ No newline at end of file +{"type":"tag","loc":{"start":{"line":1,"column":1},"filename":"/cases/block-expansion.shorthands.pug","end":{"line":1,"column":3}},"val":"ul"} +{"type":"indent","loc":{"start":{"line":2,"column":1},"filename":"/cases/block-expansion.shorthands.pug","end":{"line":2,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":2,"column":3},"filename":"/cases/block-expansion.shorthands.pug","end":{"line":2,"column":5}},"val":"li"} +{"type":"class","loc":{"start":{"line":2,"column":5},"filename":"/cases/block-expansion.shorthands.pug","end":{"line":2,"column":15}},"val":"list-item"} +{"type":":","loc":{"start":{"line":2,"column":15},"filename":"/cases/block-expansion.shorthands.pug","end":{"line":2,"column":17}}} +{"type":"class","loc":{"start":{"line":2,"column":17},"filename":"/cases/block-expansion.shorthands.pug","end":{"line":2,"column":21}},"val":"foo"} +{"type":":","loc":{"start":{"line":2,"column":21},"filename":"/cases/block-expansion.shorthands.pug","end":{"line":2,"column":23}}} +{"type":"id","loc":{"start":{"line":2,"column":23},"filename":"/cases/block-expansion.shorthands.pug","end":{"line":2,"column":27}},"val":"bar"} +{"type":"text","loc":{"start":{"line":2,"column":28},"filename":"/cases/block-expansion.shorthands.pug","end":{"line":2,"column":31}},"val":"baz"} +{"type":"outdent","loc":{"start":{"line":2,"column":31},"filename":"/cases/block-expansion.shorthands.pug","end":{"line":2,"column":31}}} +{"type":"eos","loc":{"start":{"line":2,"column":31},"filename":"/cases/block-expansion.shorthands.pug","end":{"line":2,"column":31}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/block-expansion.tokens.json b/packages/pug-parser/test/cases/block-expansion.tokens.json index e975377c7..c49b6599a 100644 --- a/packages/pug-parser/test/cases/block-expansion.tokens.json +++ b/packages/pug-parser/test/cases/block-expansion.tokens.json @@ -1,21 +1,21 @@ -{"type":"tag","line":1,"col":1,"val":"ul"} -{"type":"indent","line":2,"col":1,"val":2} -{"type":"tag","line":2,"col":3,"val":"li"} -{"type":":","line":2,"col":5} -{"type":"tag","line":2,"col":7,"val":"a"} -{"type":"start-attributes","line":2,"col":8} -{"type":"attribute","line":2,"col":9,"name":"href","val":"'#'","mustEscape":true} -{"type":"end-attributes","line":2,"col":17} -{"type":"text","line":2,"col":19,"val":"foo"} -{"type":"newline","line":3,"col":1} -{"type":"tag","line":3,"col":3,"val":"li"} -{"type":":","line":3,"col":5} -{"type":"tag","line":3,"col":7,"val":"a"} -{"type":"start-attributes","line":3,"col":8} -{"type":"attribute","line":3,"col":9,"name":"href","val":"'#'","mustEscape":true} -{"type":"end-attributes","line":3,"col":17} -{"type":"text","line":3,"col":19,"val":"bar"} -{"type":"outdent","line":5,"col":1} -{"type":"tag","line":5,"col":1,"val":"p"} -{"type":"text","line":5,"col":3,"val":"baz"} -{"type":"eos","line":5,"col":6} \ No newline at end of file +{"type":"tag","loc":{"start":{"line":1,"column":1},"filename":"/cases/block-expansion.pug","end":{"line":1,"column":3}},"val":"ul"} +{"type":"indent","loc":{"start":{"line":2,"column":1},"filename":"/cases/block-expansion.pug","end":{"line":2,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":2,"column":3},"filename":"/cases/block-expansion.pug","end":{"line":2,"column":5}},"val":"li"} +{"type":":","loc":{"start":{"line":2,"column":5},"filename":"/cases/block-expansion.pug","end":{"line":2,"column":7}}} +{"type":"tag","loc":{"start":{"line":2,"column":7},"filename":"/cases/block-expansion.pug","end":{"line":2,"column":8}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":2,"column":8},"filename":"/cases/block-expansion.pug","end":{"line":2,"column":9}}} +{"type":"attribute","loc":{"start":{"line":2,"column":9},"filename":"/cases/block-expansion.pug","end":{"line":2,"column":17}},"name":"href","mustEscape":true,"val":"'#'"} +{"type":"end-attributes","loc":{"start":{"line":2,"column":17},"filename":"/cases/block-expansion.pug","end":{"line":2,"column":18}}} +{"type":"text","loc":{"start":{"line":2,"column":19},"filename":"/cases/block-expansion.pug","end":{"line":2,"column":22}},"val":"foo"} +{"type":"newline","loc":{"start":{"line":3,"column":1},"filename":"/cases/block-expansion.pug","end":{"line":3,"column":3}}} +{"type":"tag","loc":{"start":{"line":3,"column":3},"filename":"/cases/block-expansion.pug","end":{"line":3,"column":5}},"val":"li"} +{"type":":","loc":{"start":{"line":3,"column":5},"filename":"/cases/block-expansion.pug","end":{"line":3,"column":7}}} +{"type":"tag","loc":{"start":{"line":3,"column":7},"filename":"/cases/block-expansion.pug","end":{"line":3,"column":8}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":3,"column":8},"filename":"/cases/block-expansion.pug","end":{"line":3,"column":9}}} +{"type":"attribute","loc":{"start":{"line":3,"column":9},"filename":"/cases/block-expansion.pug","end":{"line":3,"column":17}},"name":"href","mustEscape":true,"val":"'#'"} +{"type":"end-attributes","loc":{"start":{"line":3,"column":17},"filename":"/cases/block-expansion.pug","end":{"line":3,"column":18}}} +{"type":"text","loc":{"start":{"line":3,"column":19},"filename":"/cases/block-expansion.pug","end":{"line":3,"column":22}},"val":"bar"} +{"type":"outdent","loc":{"start":{"line":5,"column":1},"filename":"/cases/block-expansion.pug","end":{"line":5,"column":1}}} +{"type":"tag","loc":{"start":{"line":5,"column":1},"filename":"/cases/block-expansion.pug","end":{"line":5,"column":2}},"val":"p"} +{"type":"text","loc":{"start":{"line":5,"column":3},"filename":"/cases/block-expansion.pug","end":{"line":5,"column":6}},"val":"baz"} +{"type":"eos","loc":{"start":{"line":5,"column":6},"filename":"/cases/block-expansion.pug","end":{"line":5,"column":6}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/blockquote.tokens.json b/packages/pug-parser/test/cases/blockquote.tokens.json index d03499a1c..cb0b8f0c6 100644 --- a/packages/pug-parser/test/cases/blockquote.tokens.json +++ b/packages/pug-parser/test/cases/blockquote.tokens.json @@ -1,10 +1,10 @@ -{"type":"tag","line":1,"col":1,"val":"figure"} -{"type":"indent","line":2,"col":1,"val":2} -{"type":"tag","line":2,"col":3,"val":"blockquote"} -{"type":"indent","line":3,"col":1,"val":4} -{"type":"text","line":3,"col":7,"val":"Try to define yourself by what you do, and you’ll burnout every time. You are. That is enough. I rest in that."} -{"type":"outdent","line":4,"col":3} -{"type":"tag","line":4,"col":3,"val":"figcaption"} -{"type":"text","line":4,"col":14,"val":"from @thefray at 1:43pm on May 10"} -{"type":"outdent","line":4,"col":47} -{"type":"eos","line":4,"col":47} \ No newline at end of file +{"type":"tag","loc":{"start":{"line":1,"column":1},"filename":"/cases/blockquote.pug","end":{"line":1,"column":7}},"val":"figure"} +{"type":"indent","loc":{"start":{"line":2,"column":1},"filename":"/cases/blockquote.pug","end":{"line":2,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":2,"column":3},"filename":"/cases/blockquote.pug","end":{"line":2,"column":13}},"val":"blockquote"} +{"type":"indent","loc":{"start":{"line":3,"column":1},"filename":"/cases/blockquote.pug","end":{"line":3,"column":5}},"val":4} +{"type":"text","loc":{"start":{"line":3,"column":7},"filename":"/cases/blockquote.pug","end":{"line":3,"column":123}},"val":"Try to define yourself by what you do, and you’ll burnout every time. You are. That is enough. I rest in that."} +{"type":"outdent","loc":{"start":{"line":4,"column":1},"filename":"/cases/blockquote.pug","end":{"line":4,"column":3}}} +{"type":"tag","loc":{"start":{"line":4,"column":3},"filename":"/cases/blockquote.pug","end":{"line":4,"column":13}},"val":"figcaption"} +{"type":"text","loc":{"start":{"line":4,"column":14},"filename":"/cases/blockquote.pug","end":{"line":4,"column":47}},"val":"from @thefray at 1:43pm on May 10"} +{"type":"outdent","loc":{"start":{"line":4,"column":47},"filename":"/cases/blockquote.pug","end":{"line":4,"column":47}}} +{"type":"eos","loc":{"start":{"line":4,"column":47},"filename":"/cases/blockquote.pug","end":{"line":4,"column":47}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/blocks-in-blocks.tokens.json b/packages/pug-parser/test/cases/blocks-in-blocks.tokens.json index b02900153..c3cb941ea 100644 --- a/packages/pug-parser/test/cases/blocks-in-blocks.tokens.json +++ b/packages/pug-parser/test/cases/blocks-in-blocks.tokens.json @@ -1,9 +1,9 @@ -{"type":"extends","line":1,"col":1} -{"type":"path","line":1,"col":9,"val":"./auxiliary/blocks-in-blocks-layout.pug"} -{"type":"newline","line":3,"col":1} -{"type":"block","line":3,"col":1,"val":"body","mode":"replace"} -{"type":"indent","line":4,"col":1,"val":2} -{"type":"tag","line":4,"col":3,"val":"h1"} -{"type":"text","line":4,"col":6,"val":"Page 2"} -{"type":"outdent","line":5,"col":1} -{"type":"eos","line":5,"col":1} \ No newline at end of file +{"type":"extends","loc":{"start":{"line":1,"column":1},"filename":"/cases/blocks-in-blocks.pug","end":{"line":1,"column":8}}} +{"type":"path","loc":{"start":{"line":1,"column":9},"filename":"/cases/blocks-in-blocks.pug","end":{"line":1,"column":48}},"val":"./auxiliary/blocks-in-blocks-layout.pug"} +{"type":"newline","loc":{"start":{"line":3,"column":1},"filename":"/cases/blocks-in-blocks.pug","end":{"line":3,"column":1}}} +{"type":"block","loc":{"start":{"line":3,"column":1},"filename":"/cases/blocks-in-blocks.pug","end":{"line":3,"column":11}},"val":"body","mode":"replace"} +{"type":"indent","loc":{"start":{"line":4,"column":1},"filename":"/cases/blocks-in-blocks.pug","end":{"line":4,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":4,"column":3},"filename":"/cases/blocks-in-blocks.pug","end":{"line":4,"column":5}},"val":"h1"} +{"type":"text","loc":{"start":{"line":4,"column":6},"filename":"/cases/blocks-in-blocks.pug","end":{"line":4,"column":12}},"val":"Page 2"} +{"type":"outdent","loc":{"start":{"line":5,"column":1},"filename":"/cases/blocks-in-blocks.pug","end":{"line":5,"column":1}}} +{"type":"eos","loc":{"start":{"line":5,"column":1},"filename":"/cases/blocks-in-blocks.pug","end":{"line":5,"column":1}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/blocks-in-if.tokens.json b/packages/pug-parser/test/cases/blocks-in-if.tokens.json index cacfebd6f..3f30fc324 100644 --- a/packages/pug-parser/test/cases/blocks-in-if.tokens.json +++ b/packages/pug-parser/test/cases/blocks-in-if.tokens.json @@ -1,44 +1,44 @@ -{"type":"comment","line":1,"col":1,"val":" see https://github.com/pugjs/pug/issues/1589","buffer":false} -{"type":"newline","line":3,"col":1} -{"type":"code","line":3,"col":1,"val":"var ajax = true","mustEscape":false,"buffer":false} -{"type":"newline","line":5,"col":1} -{"type":"code","line":5,"col":1,"val":"if( ajax )","mustEscape":false,"buffer":false} -{"type":"indent","line":6,"col":1,"val":4} -{"type":"comment","line":6,"col":5,"val":" return only contents if ajax requests","buffer":false} -{"type":"newline","line":7,"col":1} -{"type":"block","line":7,"col":5,"val":"contents","mode":"replace"} -{"type":"indent","line":8,"col":1,"val":8} -{"type":"tag","line":8,"col":9,"val":"p"} -{"type":"text","line":8,"col":11,"val":"ajax contents"} -{"type":"outdent","line":10,"col":5} -{"type":"outdent","line":10,"col":1} -{"type":"code","line":10,"col":1,"val":"else","mustEscape":false,"buffer":false} -{"type":"indent","line":11,"col":1,"val":4} -{"type":"comment","line":11,"col":5,"val":" return all html","buffer":false} -{"type":"newline","line":12,"col":1} -{"type":"doctype","line":12,"col":5,"val":"html"} -{"type":"newline","line":13,"col":1} -{"type":"tag","line":13,"col":5,"val":"html"} -{"type":"indent","line":14,"col":1,"val":8} -{"type":"tag","line":14,"col":9,"val":"head"} -{"type":"indent","line":15,"col":1,"val":12} -{"type":"tag","line":15,"col":13,"val":"meta"} -{"type":"start-attributes","line":15,"col":17} -{"type":"attribute","line":15,"col":19,"name":"charset","val":"'utf8'","mustEscape":true} -{"type":"end-attributes","line":15,"col":34} -{"type":"newline","line":16,"col":1} -{"type":"tag","line":16,"col":13,"val":"title"} -{"type":"text","line":16,"col":19,"val":"sample"} -{"type":"newline","line":17,"col":1} -{"type":"tag","line":17,"col":13,"val":"body"} -{"type":"indent","line":18,"col":1,"val":16} -{"type":"block","line":18,"col":17,"val":"contents","mode":"replace"} -{"type":"indent","line":19,"col":1,"val":20} -{"type":"tag","line":19,"col":21,"val":"p"} -{"type":"text","line":19,"col":23,"val":"all contetns"} -{"type":"outdent","line":20,"col":17} -{"type":"outdent","line":20,"col":13} -{"type":"outdent","line":20,"col":9} -{"type":"outdent","line":20,"col":5} -{"type":"outdent","line":20,"col":1} -{"type":"eos","line":20,"col":1} \ No newline at end of file +{"type":"comment","loc":{"start":{"line":1,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":1,"column":49}},"val":" see https://github.com/pugjs/pug/issues/1589","buffer":false} +{"type":"newline","loc":{"start":{"line":3,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":3,"column":1}}} +{"type":"code","loc":{"start":{"line":3,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":3,"column":17}},"val":"var ajax = true","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":5,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":5,"column":1}}} +{"type":"code","loc":{"start":{"line":5,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":5,"column":12}},"val":"if( ajax )","mustEscape":false,"buffer":false} +{"type":"indent","loc":{"start":{"line":6,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":6,"column":5}},"val":4} +{"type":"comment","loc":{"start":{"line":6,"column":5},"filename":"/cases/blocks-in-if.pug","end":{"line":6,"column":46}},"val":" return only contents if ajax requests","buffer":false} +{"type":"newline","loc":{"start":{"line":7,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":7,"column":5}}} +{"type":"block","loc":{"start":{"line":7,"column":5},"filename":"/cases/blocks-in-if.pug","end":{"line":7,"column":19}},"val":"contents","mode":"replace"} +{"type":"indent","loc":{"start":{"line":8,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":8,"column":9}},"val":8} +{"type":"tag","loc":{"start":{"line":8,"column":9},"filename":"/cases/blocks-in-if.pug","end":{"line":8,"column":10}},"val":"p"} +{"type":"text","loc":{"start":{"line":8,"column":11},"filename":"/cases/blocks-in-if.pug","end":{"line":8,"column":24}},"val":"ajax contents"} +{"type":"outdent","loc":{"start":{"line":10,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":10,"column":1}}} +{"type":"outdent","loc":{"start":{"line":10,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":10,"column":1}}} +{"type":"code","loc":{"start":{"line":10,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":10,"column":6}},"val":"else","mustEscape":false,"buffer":false} +{"type":"indent","loc":{"start":{"line":11,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":11,"column":5}},"val":4} +{"type":"comment","loc":{"start":{"line":11,"column":5},"filename":"/cases/blocks-in-if.pug","end":{"line":11,"column":24}},"val":" return all html","buffer":false} +{"type":"newline","loc":{"start":{"line":12,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":12,"column":5}}} +{"type":"doctype","loc":{"start":{"line":12,"column":5},"filename":"/cases/blocks-in-if.pug","end":{"line":12,"column":17}},"val":"html"} +{"type":"newline","loc":{"start":{"line":13,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":13,"column":5}}} +{"type":"tag","loc":{"start":{"line":13,"column":5},"filename":"/cases/blocks-in-if.pug","end":{"line":13,"column":9}},"val":"html"} +{"type":"indent","loc":{"start":{"line":14,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":14,"column":9}},"val":8} +{"type":"tag","loc":{"start":{"line":14,"column":9},"filename":"/cases/blocks-in-if.pug","end":{"line":14,"column":13}},"val":"head"} +{"type":"indent","loc":{"start":{"line":15,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":15,"column":13}},"val":12} +{"type":"tag","loc":{"start":{"line":15,"column":13},"filename":"/cases/blocks-in-if.pug","end":{"line":15,"column":17}},"val":"meta"} +{"type":"start-attributes","loc":{"start":{"line":15,"column":17},"filename":"/cases/blocks-in-if.pug","end":{"line":15,"column":18}}} +{"type":"attribute","loc":{"start":{"line":15,"column":19},"filename":"/cases/blocks-in-if.pug","end":{"line":15,"column":33}},"name":"charset","mustEscape":true,"val":"'utf8'"} +{"type":"end-attributes","loc":{"start":{"line":15,"column":34},"filename":"/cases/blocks-in-if.pug","end":{"line":15,"column":35}}} +{"type":"newline","loc":{"start":{"line":16,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":16,"column":13}}} +{"type":"tag","loc":{"start":{"line":16,"column":13},"filename":"/cases/blocks-in-if.pug","end":{"line":16,"column":18}},"val":"title"} +{"type":"text","loc":{"start":{"line":16,"column":19},"filename":"/cases/blocks-in-if.pug","end":{"line":16,"column":25}},"val":"sample"} +{"type":"newline","loc":{"start":{"line":17,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":17,"column":13}}} +{"type":"tag","loc":{"start":{"line":17,"column":13},"filename":"/cases/blocks-in-if.pug","end":{"line":17,"column":17}},"val":"body"} +{"type":"indent","loc":{"start":{"line":18,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":18,"column":17}},"val":16} +{"type":"block","loc":{"start":{"line":18,"column":17},"filename":"/cases/blocks-in-if.pug","end":{"line":18,"column":31}},"val":"contents","mode":"replace"} +{"type":"indent","loc":{"start":{"line":19,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":19,"column":21}},"val":20} +{"type":"tag","loc":{"start":{"line":19,"column":21},"filename":"/cases/blocks-in-if.pug","end":{"line":19,"column":22}},"val":"p"} +{"type":"text","loc":{"start":{"line":19,"column":23},"filename":"/cases/blocks-in-if.pug","end":{"line":19,"column":35}},"val":"all contetns"} +{"type":"outdent","loc":{"start":{"line":20,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":20,"column":1}}} +{"type":"outdent","loc":{"start":{"line":20,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":20,"column":1}}} +{"type":"outdent","loc":{"start":{"line":20,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":20,"column":1}}} +{"type":"outdent","loc":{"start":{"line":20,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":20,"column":1}}} +{"type":"outdent","loc":{"start":{"line":20,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":20,"column":1}}} +{"type":"eos","loc":{"start":{"line":20,"column":1},"filename":"/cases/blocks-in-if.pug","end":{"line":20,"column":1}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/case-blocks.tokens.json b/packages/pug-parser/test/cases/case-blocks.tokens.json index b56e19ac6..165b477ce 100644 --- a/packages/pug-parser/test/cases/case-blocks.tokens.json +++ b/packages/pug-parser/test/cases/case-blocks.tokens.json @@ -1,29 +1,29 @@ -{"type":"tag","line":1,"col":1,"val":"html"} -{"type":"indent","line":2,"col":1,"val":2} -{"type":"tag","line":2,"col":3,"val":"body"} -{"type":"indent","line":3,"col":1,"val":4} -{"type":"code","line":3,"col":5,"val":"var friends = 1","mustEscape":false,"buffer":false} -{"type":"newline","line":4,"col":1} -{"type":"case","line":4,"col":5,"val":"friends"} -{"type":"indent","line":5,"col":1,"val":6} -{"type":"when","line":5,"col":7,"val":"0"} -{"type":"indent","line":6,"col":1,"val":8} -{"type":"tag","line":6,"col":9,"val":"p"} -{"type":"text","line":6,"col":11,"val":"you have no friends"} -{"type":"outdent","line":7,"col":7} -{"type":"when","line":7,"col":7,"val":"1"} -{"type":"indent","line":8,"col":1,"val":8} -{"type":"tag","line":8,"col":9,"val":"p"} -{"type":"text","line":8,"col":11,"val":"you have a friend"} -{"type":"outdent","line":9,"col":7} -{"type":"default","line":9,"col":7} -{"type":"indent","line":10,"col":1,"val":8} -{"type":"tag","line":10,"col":9,"val":"p"} -{"type":"text","line":10,"col":11,"val":"you have "} -{"type":"interpolated-code","line":10,"col":20,"val":"friends","mustEscape":true,"buffer":true} -{"type":"text","line":10,"col":30,"val":" friends"} -{"type":"outdent","line":10,"col":38} -{"type":"outdent","line":10,"col":38} -{"type":"outdent","line":10,"col":38} -{"type":"outdent","line":10,"col":38} -{"type":"eos","line":10,"col":38} \ No newline at end of file +{"type":"tag","loc":{"start":{"line":1,"column":1},"filename":"/cases/case-blocks.pug","end":{"line":1,"column":5}},"val":"html"} +{"type":"indent","loc":{"start":{"line":2,"column":1},"filename":"/cases/case-blocks.pug","end":{"line":2,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":2,"column":3},"filename":"/cases/case-blocks.pug","end":{"line":2,"column":7}},"val":"body"} +{"type":"indent","loc":{"start":{"line":3,"column":1},"filename":"/cases/case-blocks.pug","end":{"line":3,"column":5}},"val":4} +{"type":"code","loc":{"start":{"line":3,"column":5},"filename":"/cases/case-blocks.pug","end":{"line":3,"column":22}},"val":"var friends = 1","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":4,"column":1},"filename":"/cases/case-blocks.pug","end":{"line":4,"column":5}}} +{"type":"case","loc":{"start":{"line":4,"column":5},"filename":"/cases/case-blocks.pug","end":{"line":4,"column":17}},"val":"friends"} +{"type":"indent","loc":{"start":{"line":5,"column":1},"filename":"/cases/case-blocks.pug","end":{"line":5,"column":7}},"val":6} +{"type":"when","loc":{"start":{"line":5,"column":7},"filename":"/cases/case-blocks.pug","end":{"line":5,"column":13}},"val":"0"} +{"type":"indent","loc":{"start":{"line":6,"column":1},"filename":"/cases/case-blocks.pug","end":{"line":6,"column":9}},"val":8} +{"type":"tag","loc":{"start":{"line":6,"column":9},"filename":"/cases/case-blocks.pug","end":{"line":6,"column":10}},"val":"p"} +{"type":"text","loc":{"start":{"line":6,"column":11},"filename":"/cases/case-blocks.pug","end":{"line":6,"column":30}},"val":"you have no friends"} +{"type":"outdent","loc":{"start":{"line":7,"column":1},"filename":"/cases/case-blocks.pug","end":{"line":7,"column":7}}} +{"type":"when","loc":{"start":{"line":7,"column":7},"filename":"/cases/case-blocks.pug","end":{"line":7,"column":13}},"val":"1"} +{"type":"indent","loc":{"start":{"line":8,"column":1},"filename":"/cases/case-blocks.pug","end":{"line":8,"column":9}},"val":8} +{"type":"tag","loc":{"start":{"line":8,"column":9},"filename":"/cases/case-blocks.pug","end":{"line":8,"column":10}},"val":"p"} +{"type":"text","loc":{"start":{"line":8,"column":11},"filename":"/cases/case-blocks.pug","end":{"line":8,"column":28}},"val":"you have a friend"} +{"type":"outdent","loc":{"start":{"line":9,"column":1},"filename":"/cases/case-blocks.pug","end":{"line":9,"column":7}}} +{"type":"default","loc":{"start":{"line":9,"column":7},"filename":"/cases/case-blocks.pug","end":{"line":9,"column":14}}} +{"type":"indent","loc":{"start":{"line":10,"column":1},"filename":"/cases/case-blocks.pug","end":{"line":10,"column":9}},"val":8} +{"type":"tag","loc":{"start":{"line":10,"column":9},"filename":"/cases/case-blocks.pug","end":{"line":10,"column":10}},"val":"p"} +{"type":"text","loc":{"start":{"line":10,"column":11},"filename":"/cases/case-blocks.pug","end":{"line":10,"column":20}},"val":"you have "} +{"type":"interpolated-code","loc":{"start":{"line":10,"column":20},"filename":"/cases/case-blocks.pug","end":{"line":10,"column":30}},"mustEscape":true,"buffer":true,"val":"friends"} +{"type":"text","loc":{"start":{"line":10,"column":30},"filename":"/cases/case-blocks.pug","end":{"line":10,"column":38}},"val":" friends"} +{"type":"outdent","loc":{"start":{"line":10,"column":38},"filename":"/cases/case-blocks.pug","end":{"line":10,"column":38}}} +{"type":"outdent","loc":{"start":{"line":10,"column":38},"filename":"/cases/case-blocks.pug","end":{"line":10,"column":38}}} +{"type":"outdent","loc":{"start":{"line":10,"column":38},"filename":"/cases/case-blocks.pug","end":{"line":10,"column":38}}} +{"type":"outdent","loc":{"start":{"line":10,"column":38},"filename":"/cases/case-blocks.pug","end":{"line":10,"column":38}}} +{"type":"eos","loc":{"start":{"line":10,"column":38},"filename":"/cases/case-blocks.pug","end":{"line":10,"column":38}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/case.tokens.json b/packages/pug-parser/test/cases/case.tokens.json index cbfdcb5fd..da7847e53 100644 --- a/packages/pug-parser/test/cases/case.tokens.json +++ b/packages/pug-parser/test/cases/case.tokens.json @@ -1,47 +1,61 @@ -{"type":"tag","line":1,"col":1,"val":"html"} -{"type":"indent","line":2,"col":1,"val":2} -{"type":"tag","line":2,"col":3,"val":"body"} -{"type":"indent","line":3,"col":1,"val":4} -{"type":"code","line":3,"col":5,"val":"var friends = 1","mustEscape":false,"buffer":false} -{"type":"newline","line":4,"col":1} -{"type":"case","line":4,"col":5,"val":"friends"} -{"type":"indent","line":5,"col":1,"val":6} -{"type":"when","line":5,"col":7,"val":"0"} -{"type":":","line":5,"col":13} -{"type":"tag","line":5,"col":15,"val":"p"} -{"type":"text","line":5,"col":17,"val":"you have no friends"} -{"type":"newline","line":6,"col":1} -{"type":"when","line":6,"col":7,"val":"1"} -{"type":":","line":6,"col":13} -{"type":"tag","line":6,"col":15,"val":"p"} -{"type":"text","line":6,"col":17,"val":"you have a friend"} -{"type":"newline","line":7,"col":1} -{"type":"default","line":7,"col":7} -{"type":":","line":7,"col":14} -{"type":"tag","line":7,"col":16,"val":"p"} -{"type":"text","line":7,"col":18,"val":"you have "} -{"type":"interpolated-code","line":7,"col":27,"val":"friends","mustEscape":true,"buffer":true} -{"type":"text","line":7,"col":37,"val":" friends"} -{"type":"outdent","line":8,"col":5} -{"type":"code","line":8,"col":5,"val":"var friends = 0","mustEscape":false,"buffer":false} -{"type":"newline","line":9,"col":1} -{"type":"case","line":9,"col":5,"val":"friends"} -{"type":"indent","line":10,"col":1,"val":6} -{"type":"when","line":10,"col":7,"val":"0"} -{"type":"newline","line":11,"col":1} -{"type":"when","line":11,"col":7,"val":"1"} -{"type":"indent","line":12,"col":1,"val":8} -{"type":"tag","line":12,"col":9,"val":"p"} -{"type":"text","line":12,"col":11,"val":"you have very few friends"} -{"type":"outdent","line":13,"col":7} -{"type":"default","line":13,"col":7} -{"type":"indent","line":14,"col":1,"val":8} -{"type":"tag","line":14,"col":9,"val":"p"} -{"type":"text","line":14,"col":11,"val":"you have "} -{"type":"interpolated-code","line":14,"col":20,"val":"friends","mustEscape":true,"buffer":true} -{"type":"text","line":14,"col":30,"val":" friends"} -{"type":"outdent","line":14,"col":38} -{"type":"outdent","line":14,"col":38} -{"type":"outdent","line":14,"col":38} -{"type":"outdent","line":14,"col":38} -{"type":"eos","line":14,"col":38} \ No newline at end of file +{"type":"tag","loc":{"start":{"line":1,"column":1},"filename":"/cases/case.pug","end":{"line":1,"column":5}},"val":"html"} +{"type":"indent","loc":{"start":{"line":2,"column":1},"filename":"/cases/case.pug","end":{"line":2,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":2,"column":3},"filename":"/cases/case.pug","end":{"line":2,"column":7}},"val":"body"} +{"type":"indent","loc":{"start":{"line":3,"column":1},"filename":"/cases/case.pug","end":{"line":3,"column":5}},"val":4} +{"type":"code","loc":{"start":{"line":3,"column":5},"filename":"/cases/case.pug","end":{"line":3,"column":22}},"val":"var friends = 1","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":4,"column":1},"filename":"/cases/case.pug","end":{"line":4,"column":5}}} +{"type":"case","loc":{"start":{"line":4,"column":5},"filename":"/cases/case.pug","end":{"line":4,"column":17}},"val":"friends"} +{"type":"indent","loc":{"start":{"line":5,"column":1},"filename":"/cases/case.pug","end":{"line":5,"column":7}},"val":6} +{"type":"when","loc":{"start":{"line":5,"column":7},"filename":"/cases/case.pug","end":{"line":5,"column":13}},"val":"0"} +{"type":":","loc":{"start":{"line":5,"column":13},"filename":"/cases/case.pug","end":{"line":5,"column":15}}} +{"type":"tag","loc":{"start":{"line":5,"column":15},"filename":"/cases/case.pug","end":{"line":5,"column":16}},"val":"p"} +{"type":"text","loc":{"start":{"line":5,"column":17},"filename":"/cases/case.pug","end":{"line":5,"column":36}},"val":"you have no friends"} +{"type":"newline","loc":{"start":{"line":6,"column":1},"filename":"/cases/case.pug","end":{"line":6,"column":7}}} +{"type":"when","loc":{"start":{"line":6,"column":7},"filename":"/cases/case.pug","end":{"line":6,"column":13}},"val":"1"} +{"type":":","loc":{"start":{"line":6,"column":13},"filename":"/cases/case.pug","end":{"line":6,"column":15}}} +{"type":"tag","loc":{"start":{"line":6,"column":15},"filename":"/cases/case.pug","end":{"line":6,"column":16}},"val":"p"} +{"type":"text","loc":{"start":{"line":6,"column":17},"filename":"/cases/case.pug","end":{"line":6,"column":34}},"val":"you have a friend"} +{"type":"newline","loc":{"start":{"line":7,"column":1},"filename":"/cases/case.pug","end":{"line":7,"column":7}}} +{"type":"default","loc":{"start":{"line":7,"column":7},"filename":"/cases/case.pug","end":{"line":7,"column":14}}} +{"type":":","loc":{"start":{"line":7,"column":14},"filename":"/cases/case.pug","end":{"line":7,"column":16}}} +{"type":"tag","loc":{"start":{"line":7,"column":16},"filename":"/cases/case.pug","end":{"line":7,"column":17}},"val":"p"} +{"type":"text","loc":{"start":{"line":7,"column":18},"filename":"/cases/case.pug","end":{"line":7,"column":27}},"val":"you have "} +{"type":"interpolated-code","loc":{"start":{"line":7,"column":27},"filename":"/cases/case.pug","end":{"line":7,"column":37}},"mustEscape":true,"buffer":true,"val":"friends"} +{"type":"text","loc":{"start":{"line":7,"column":37},"filename":"/cases/case.pug","end":{"line":7,"column":45}},"val":" friends"} +{"type":"outdent","loc":{"start":{"line":8,"column":1},"filename":"/cases/case.pug","end":{"line":8,"column":5}}} +{"type":"code","loc":{"start":{"line":8,"column":5},"filename":"/cases/case.pug","end":{"line":8,"column":22}},"val":"var friends = 0","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":9,"column":1},"filename":"/cases/case.pug","end":{"line":9,"column":5}}} +{"type":"case","loc":{"start":{"line":9,"column":5},"filename":"/cases/case.pug","end":{"line":9,"column":17}},"val":"friends"} +{"type":"indent","loc":{"start":{"line":10,"column":1},"filename":"/cases/case.pug","end":{"line":10,"column":7}},"val":6} +{"type":"when","loc":{"start":{"line":10,"column":7},"filename":"/cases/case.pug","end":{"line":10,"column":13}},"val":"0"} +{"type":"newline","loc":{"start":{"line":11,"column":1},"filename":"/cases/case.pug","end":{"line":11,"column":7}}} +{"type":"when","loc":{"start":{"line":11,"column":7},"filename":"/cases/case.pug","end":{"line":11,"column":13}},"val":"1"} +{"type":"indent","loc":{"start":{"line":12,"column":1},"filename":"/cases/case.pug","end":{"line":12,"column":9}},"val":8} +{"type":"tag","loc":{"start":{"line":12,"column":9},"filename":"/cases/case.pug","end":{"line":12,"column":10}},"val":"p"} +{"type":"text","loc":{"start":{"line":12,"column":11},"filename":"/cases/case.pug","end":{"line":12,"column":36}},"val":"you have very few friends"} +{"type":"outdent","loc":{"start":{"line":13,"column":1},"filename":"/cases/case.pug","end":{"line":13,"column":7}}} +{"type":"default","loc":{"start":{"line":13,"column":7},"filename":"/cases/case.pug","end":{"line":13,"column":14}}} +{"type":"indent","loc":{"start":{"line":14,"column":1},"filename":"/cases/case.pug","end":{"line":14,"column":9}},"val":8} +{"type":"tag","loc":{"start":{"line":14,"column":9},"filename":"/cases/case.pug","end":{"line":14,"column":10}},"val":"p"} +{"type":"text","loc":{"start":{"line":14,"column":11},"filename":"/cases/case.pug","end":{"line":14,"column":20}},"val":"you have "} +{"type":"interpolated-code","loc":{"start":{"line":14,"column":20},"filename":"/cases/case.pug","end":{"line":14,"column":30}},"mustEscape":true,"buffer":true,"val":"friends"} +{"type":"text","loc":{"start":{"line":14,"column":30},"filename":"/cases/case.pug","end":{"line":14,"column":38}},"val":" friends"} +{"type":"outdent","loc":{"start":{"line":16,"column":1},"filename":"/cases/case.pug","end":{"line":16,"column":5}}} +{"type":"outdent","loc":{"start":{"line":16,"column":1},"filename":"/cases/case.pug","end":{"line":16,"column":5}}} +{"type":"code","loc":{"start":{"line":16,"column":5},"filename":"/cases/case.pug","end":{"line":16,"column":27}},"val":"var friend = 'Tim:G'","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":17,"column":1},"filename":"/cases/case.pug","end":{"line":17,"column":5}}} +{"type":"case","loc":{"start":{"line":17,"column":5},"filename":"/cases/case.pug","end":{"line":17,"column":16}},"val":"friend"} +{"type":"indent","loc":{"start":{"line":18,"column":1},"filename":"/cases/case.pug","end":{"line":18,"column":7}},"val":6} +{"type":"when","loc":{"start":{"line":18,"column":7},"filename":"/cases/case.pug","end":{"line":18,"column":19}},"val":"'Tim:G'"} +{"type":":","loc":{"start":{"line":18,"column":19},"filename":"/cases/case.pug","end":{"line":18,"column":24}}} +{"type":"tag","loc":{"start":{"line":18,"column":24},"filename":"/cases/case.pug","end":{"line":18,"column":25}},"val":"p"} +{"type":"text","loc":{"start":{"line":18,"column":26},"filename":"/cases/case.pug","end":{"line":18,"column":44}},"val":"Friend is a string"} +{"type":"newline","loc":{"start":{"line":19,"column":1},"filename":"/cases/case.pug","end":{"line":19,"column":7}}} +{"type":"when","loc":{"start":{"line":19,"column":7},"filename":"/cases/case.pug","end":{"line":19,"column":22}},"val":"{tim: 'g'}"} +{"type":":","loc":{"start":{"line":19,"column":22},"filename":"/cases/case.pug","end":{"line":19,"column":24}}} +{"type":"tag","loc":{"start":{"line":19,"column":24},"filename":"/cases/case.pug","end":{"line":19,"column":25}},"val":"p"} +{"type":"text","loc":{"start":{"line":19,"column":26},"filename":"/cases/case.pug","end":{"line":19,"column":45}},"val":"Friend is an object"} +{"type":"outdent","loc":{"start":{"line":20,"column":1},"filename":"/cases/case.pug","end":{"line":20,"column":1}}} +{"type":"outdent","loc":{"start":{"line":20,"column":1},"filename":"/cases/case.pug","end":{"line":20,"column":1}}} +{"type":"outdent","loc":{"start":{"line":20,"column":1},"filename":"/cases/case.pug","end":{"line":20,"column":1}}} +{"type":"eos","loc":{"start":{"line":20,"column":1},"filename":"/cases/case.pug","end":{"line":20,"column":1}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/classes-empty.tokens.json b/packages/pug-parser/test/cases/classes-empty.tokens.json index b470ebcda..1e9fe573b 100644 --- a/packages/pug-parser/test/cases/classes-empty.tokens.json +++ b/packages/pug-parser/test/cases/classes-empty.tokens.json @@ -1,15 +1,15 @@ -{"type":"tag","line":1,"col":1,"val":"a"} -{"type":"start-attributes","line":1,"col":2} -{"type":"attribute","line":1,"col":3,"name":"class","val":"''","mustEscape":true} -{"type":"end-attributes","line":1,"col":11} -{"type":"newline","line":2,"col":1} -{"type":"tag","line":2,"col":1,"val":"a"} -{"type":"start-attributes","line":2,"col":2} -{"type":"attribute","line":2,"col":3,"name":"class","val":"null","mustEscape":true} -{"type":"end-attributes","line":2,"col":13} -{"type":"newline","line":3,"col":1} -{"type":"tag","line":3,"col":1,"val":"a"} -{"type":"start-attributes","line":3,"col":2} -{"type":"attribute","line":3,"col":3,"name":"class","val":"undefined","mustEscape":true} -{"type":"end-attributes","line":3,"col":18} -{"type":"eos","line":3,"col":19} \ No newline at end of file +{"type":"tag","loc":{"start":{"line":1,"column":1},"filename":"/cases/classes-empty.pug","end":{"line":1,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":1,"column":2},"filename":"/cases/classes-empty.pug","end":{"line":1,"column":3}}} +{"type":"attribute","loc":{"start":{"line":1,"column":3},"filename":"/cases/classes-empty.pug","end":{"line":1,"column":11}},"name":"class","mustEscape":true,"val":"''"} +{"type":"end-attributes","loc":{"start":{"line":1,"column":11},"filename":"/cases/classes-empty.pug","end":{"line":1,"column":12}}} +{"type":"newline","loc":{"start":{"line":2,"column":1},"filename":"/cases/classes-empty.pug","end":{"line":2,"column":1}}} +{"type":"tag","loc":{"start":{"line":2,"column":1},"filename":"/cases/classes-empty.pug","end":{"line":2,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":2,"column":2},"filename":"/cases/classes-empty.pug","end":{"line":2,"column":3}}} +{"type":"attribute","loc":{"start":{"line":2,"column":3},"filename":"/cases/classes-empty.pug","end":{"line":2,"column":13}},"name":"class","mustEscape":true,"val":"null"} +{"type":"end-attributes","loc":{"start":{"line":2,"column":13},"filename":"/cases/classes-empty.pug","end":{"line":2,"column":14}}} +{"type":"newline","loc":{"start":{"line":3,"column":1},"filename":"/cases/classes-empty.pug","end":{"line":3,"column":1}}} +{"type":"tag","loc":{"start":{"line":3,"column":1},"filename":"/cases/classes-empty.pug","end":{"line":3,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":3,"column":2},"filename":"/cases/classes-empty.pug","end":{"line":3,"column":3}}} +{"type":"attribute","loc":{"start":{"line":3,"column":3},"filename":"/cases/classes-empty.pug","end":{"line":3,"column":18}},"name":"class","mustEscape":true,"val":"undefined"} +{"type":"end-attributes","loc":{"start":{"line":3,"column":18},"filename":"/cases/classes-empty.pug","end":{"line":3,"column":19}}} +{"type":"eos","loc":{"start":{"line":3,"column":19},"filename":"/cases/classes-empty.pug","end":{"line":3,"column":19}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/classes.tokens.json b/packages/pug-parser/test/cases/classes.tokens.json index df6b13055..e5fc7ee0a 100644 --- a/packages/pug-parser/test/cases/classes.tokens.json +++ b/packages/pug-parser/test/cases/classes.tokens.json @@ -1,21 +1,27 @@ -{"type":"tag","line":1,"col":1,"val":"a"} -{"type":"start-attributes","line":1,"col":2} -{"type":"attribute","line":1,"col":3,"name":"class","val":"['foo', 'bar', 'baz']","mustEscape":true} -{"type":"end-attributes","line":1,"col":30} -{"type":"newline","line":5,"col":1} -{"type":"tag","line":5,"col":1,"val":"a"} -{"type":"class","line":5,"col":2,"val":"foo"} -{"type":"start-attributes","line":5,"col":6} -{"type":"attribute","line":5,"col":7,"name":"class","val":"'bar'","mustEscape":true} -{"type":"end-attributes","line":5,"col":18} -{"type":"class","line":5,"col":19,"val":"baz"} -{"type":"newline","line":9,"col":1} -{"type":"tag","line":9,"col":1,"val":"a"} -{"type":"class","line":9,"col":2,"val":"foo-bar_baz"} -{"type":"newline","line":11,"col":1} -{"type":"tag","line":11,"col":1,"val":"a"} -{"type":"start-attributes","line":11,"col":2} -{"type":"attribute","line":11,"col":3,"name":"class","val":"{foo: true, bar: false, baz: true}","mustEscape":true} -{"type":"end-attributes","line":11,"col":43} -{"type":"newline","line":12,"col":1} -{"type":"eos","line":12,"col":1} \ No newline at end of file +{"type":"tag","loc":{"start":{"line":1,"column":1},"filename":"/cases/classes.pug","end":{"line":1,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":1,"column":2},"filename":"/cases/classes.pug","end":{"line":1,"column":3}}} +{"type":"attribute","loc":{"start":{"line":1,"column":3},"filename":"/cases/classes.pug","end":{"line":1,"column":30}},"name":"class","mustEscape":true,"val":"['foo', 'bar', 'baz']"} +{"type":"end-attributes","loc":{"start":{"line":1,"column":30},"filename":"/cases/classes.pug","end":{"line":1,"column":31}}} +{"type":"newline","loc":{"start":{"line":5,"column":1},"filename":"/cases/classes.pug","end":{"line":5,"column":1}}} +{"type":"tag","loc":{"start":{"line":5,"column":1},"filename":"/cases/classes.pug","end":{"line":5,"column":2}},"val":"a"} +{"type":"class","loc":{"start":{"line":5,"column":2},"filename":"/cases/classes.pug","end":{"line":5,"column":6}},"val":"foo"} +{"type":"start-attributes","loc":{"start":{"line":5,"column":6},"filename":"/cases/classes.pug","end":{"line":5,"column":7}}} +{"type":"attribute","loc":{"start":{"line":5,"column":7},"filename":"/cases/classes.pug","end":{"line":5,"column":18}},"name":"class","mustEscape":true,"val":"'bar'"} +{"type":"end-attributes","loc":{"start":{"line":5,"column":18},"filename":"/cases/classes.pug","end":{"line":5,"column":19}}} +{"type":"class","loc":{"start":{"line":5,"column":19},"filename":"/cases/classes.pug","end":{"line":5,"column":23}},"val":"baz"} +{"type":"newline","loc":{"start":{"line":9,"column":1},"filename":"/cases/classes.pug","end":{"line":9,"column":1}}} +{"type":"tag","loc":{"start":{"line":9,"column":1},"filename":"/cases/classes.pug","end":{"line":9,"column":2}},"val":"a"} +{"type":"class","loc":{"start":{"line":9,"column":2},"filename":"/cases/classes.pug","end":{"line":9,"column":14}},"val":"foo-bar_baz"} +{"type":"newline","loc":{"start":{"line":11,"column":1},"filename":"/cases/classes.pug","end":{"line":11,"column":1}}} +{"type":"tag","loc":{"start":{"line":11,"column":1},"filename":"/cases/classes.pug","end":{"line":11,"column":2}},"val":"a"} +{"type":"start-attributes","loc":{"start":{"line":11,"column":2},"filename":"/cases/classes.pug","end":{"line":11,"column":3}}} +{"type":"attribute","loc":{"start":{"line":11,"column":3},"filename":"/cases/classes.pug","end":{"line":11,"column":43}},"name":"class","mustEscape":true,"val":"{foo: true, bar: false, baz: true}"} +{"type":"end-attributes","loc":{"start":{"line":11,"column":43},"filename":"/cases/classes.pug","end":{"line":11,"column":44}}} +{"type":"newline","loc":{"start":{"line":13,"column":1},"filename":"/cases/classes.pug","end":{"line":13,"column":1}}} +{"type":"tag","loc":{"start":{"line":13,"column":1},"filename":"/cases/classes.pug","end":{"line":13,"column":2}},"val":"a"} +{"type":"class","loc":{"start":{"line":13,"column":2},"filename":"/cases/classes.pug","end":{"line":13,"column":7}},"val":"-foo"} +{"type":"newline","loc":{"start":{"line":14,"column":1},"filename":"/cases/classes.pug","end":{"line":14,"column":1}}} +{"type":"tag","loc":{"start":{"line":14,"column":1},"filename":"/cases/classes.pug","end":{"line":14,"column":2}},"val":"a"} +{"type":"class","loc":{"start":{"line":14,"column":2},"filename":"/cases/classes.pug","end":{"line":14,"column":7}},"val":"3foo"} +{"type":"newline","loc":{"start":{"line":15,"column":1},"filename":"/cases/classes.pug","end":{"line":15,"column":1}}} +{"type":"eos","loc":{"start":{"line":15,"column":1},"filename":"/cases/classes.pug","end":{"line":15,"column":1}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/code.conditionals.tokens.json b/packages/pug-parser/test/cases/code.conditionals.tokens.json index 6136ca8fa..9f9d21b7b 100644 --- a/packages/pug-parser/test/cases/code.conditionals.tokens.json +++ b/packages/pug-parser/test/cases/code.conditionals.tokens.json @@ -1,86 +1,86 @@ -{"type":"newline","line":2,"col":1} -{"type":"code","line":2,"col":1,"val":"if (true)","mustEscape":false,"buffer":false} -{"type":"indent","line":3,"col":1,"val":2} -{"type":"tag","line":3,"col":3,"val":"p"} -{"type":"text","line":3,"col":5,"val":"foo"} -{"type":"outdent","line":4,"col":1} -{"type":"code","line":4,"col":1,"val":"else","mustEscape":false,"buffer":false} -{"type":"indent","line":5,"col":1,"val":2} -{"type":"tag","line":5,"col":3,"val":"p"} -{"type":"text","line":5,"col":5,"val":"bar"} -{"type":"outdent","line":7,"col":1} -{"type":"code","line":7,"col":1,"val":"if (true) {","mustEscape":false,"buffer":false} -{"type":"indent","line":8,"col":1,"val":2} -{"type":"tag","line":8,"col":3,"val":"p"} -{"type":"text","line":8,"col":5,"val":"foo"} -{"type":"outdent","line":9,"col":1} -{"type":"code","line":9,"col":1,"val":"} else {","mustEscape":false,"buffer":false} -{"type":"indent","line":10,"col":1,"val":2} -{"type":"tag","line":10,"col":3,"val":"p"} -{"type":"text","line":10,"col":5,"val":"bar"} -{"type":"outdent","line":11,"col":1} -{"type":"code","line":11,"col":1,"val":"}","mustEscape":false,"buffer":false} -{"type":"newline","line":13,"col":1} -{"type":"if","line":13,"col":1,"val":"true"} -{"type":"indent","line":14,"col":1,"val":2} -{"type":"tag","line":14,"col":3,"val":"p"} -{"type":"text","line":14,"col":5,"val":"foo"} -{"type":"newline","line":15,"col":1} -{"type":"tag","line":15,"col":3,"val":"p"} -{"type":"text","line":15,"col":5,"val":"bar"} -{"type":"newline","line":16,"col":1} -{"type":"tag","line":16,"col":3,"val":"p"} -{"type":"text","line":16,"col":5,"val":"baz"} -{"type":"outdent","line":17,"col":1} -{"type":"else","line":17,"col":1,"val":""} -{"type":"indent","line":18,"col":1,"val":2} -{"type":"tag","line":18,"col":3,"val":"p"} -{"type":"text","line":18,"col":5,"val":"bar"} -{"type":"outdent","line":20,"col":1} -{"type":"if","line":20,"col":1,"val":"!(true)"} -{"type":"indent","line":21,"col":1,"val":2} -{"type":"tag","line":21,"col":3,"val":"p"} -{"type":"text","line":21,"col":5,"val":"foo"} -{"type":"outdent","line":22,"col":1} -{"type":"else","line":22,"col":1,"val":""} -{"type":"indent","line":23,"col":1,"val":2} -{"type":"tag","line":23,"col":3,"val":"p"} -{"type":"text","line":23,"col":5,"val":"bar"} -{"type":"outdent","line":25,"col":1} -{"type":"if","line":25,"col":1,"val":"'nested'"} -{"type":"indent","line":26,"col":1,"val":2} -{"type":"if","line":26,"col":3,"val":"'works'"} -{"type":"indent","line":27,"col":1,"val":4} -{"type":"tag","line":27,"col":5,"val":"p"} -{"type":"text","line":27,"col":7,"val":"yay"} -{"type":"outdent","line":29,"col":3} -{"type":"outdent","line":29,"col":1} -{"type":"comment","line":29,"col":1,"val":" allow empty blocks","buffer":false} -{"type":"newline","line":30,"col":1} -{"type":"if","line":30,"col":1,"val":"false"} -{"type":"newline","line":31,"col":1} -{"type":"else","line":31,"col":1,"val":""} -{"type":"indent","line":32,"col":1,"val":2} -{"type":"class","line":32,"col":3,"val":"bar"} -{"type":"outdent","line":33,"col":1} -{"type":"if","line":33,"col":1,"val":"true"} -{"type":"indent","line":34,"col":1,"val":2} -{"type":"class","line":34,"col":3,"val":"bar"} -{"type":"outdent","line":35,"col":1} -{"type":"else","line":35,"col":1,"val":""} -{"type":"newline","line":36,"col":1} -{"type":"class","line":36,"col":1,"val":"bing"} -{"type":"newline","line":38,"col":1} -{"type":"if","line":38,"col":1,"val":"false"} -{"type":"indent","line":39,"col":1,"val":2} -{"type":"class","line":39,"col":3,"val":"bing"} -{"type":"outdent","line":40,"col":1} -{"type":"else-if","line":40,"col":1,"val":"false"} -{"type":"indent","line":41,"col":1,"val":2} -{"type":"class","line":41,"col":3,"val":"bar"} -{"type":"outdent","line":42,"col":1} -{"type":"else","line":42,"col":1,"val":""} -{"type":"indent","line":43,"col":1,"val":2} -{"type":"class","line":43,"col":3,"val":"foo"} -{"type":"outdent","line":43,"col":7} -{"type":"eos","line":43,"col":7} \ No newline at end of file +{"type":"newline","loc":{"start":{"line":2,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":2,"column":1}}} +{"type":"code","loc":{"start":{"line":2,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":2,"column":12}},"val":"if (true)","mustEscape":false,"buffer":false} +{"type":"indent","loc":{"start":{"line":3,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":3,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":3,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":3,"column":4}},"val":"p"} +{"type":"text","loc":{"start":{"line":3,"column":5},"filename":"/cases/code.conditionals.pug","end":{"line":3,"column":8}},"val":"foo"} +{"type":"outdent","loc":{"start":{"line":4,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":4,"column":1}}} +{"type":"code","loc":{"start":{"line":4,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":4,"column":7}},"val":"else","mustEscape":false,"buffer":false} +{"type":"indent","loc":{"start":{"line":5,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":5,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":5,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":5,"column":4}},"val":"p"} +{"type":"text","loc":{"start":{"line":5,"column":5},"filename":"/cases/code.conditionals.pug","end":{"line":5,"column":8}},"val":"bar"} +{"type":"outdent","loc":{"start":{"line":7,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":7,"column":1}}} +{"type":"code","loc":{"start":{"line":7,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":7,"column":14}},"val":"if (true) {","mustEscape":false,"buffer":false} +{"type":"indent","loc":{"start":{"line":8,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":8,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":8,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":8,"column":4}},"val":"p"} +{"type":"text","loc":{"start":{"line":8,"column":5},"filename":"/cases/code.conditionals.pug","end":{"line":8,"column":8}},"val":"foo"} +{"type":"outdent","loc":{"start":{"line":9,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":9,"column":1}}} +{"type":"code","loc":{"start":{"line":9,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":9,"column":11}},"val":"} else {","mustEscape":false,"buffer":false} +{"type":"indent","loc":{"start":{"line":10,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":10,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":10,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":10,"column":4}},"val":"p"} +{"type":"text","loc":{"start":{"line":10,"column":5},"filename":"/cases/code.conditionals.pug","end":{"line":10,"column":8}},"val":"bar"} +{"type":"outdent","loc":{"start":{"line":11,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":11,"column":1}}} +{"type":"code","loc":{"start":{"line":11,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":11,"column":4}},"val":"}","mustEscape":false,"buffer":false} +{"type":"newline","loc":{"start":{"line":13,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":13,"column":1}}} +{"type":"if","loc":{"start":{"line":13,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":13,"column":8}},"val":"true"} +{"type":"indent","loc":{"start":{"line":14,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":14,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":14,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":14,"column":4}},"val":"p"} +{"type":"text","loc":{"start":{"line":14,"column":5},"filename":"/cases/code.conditionals.pug","end":{"line":14,"column":8}},"val":"foo"} +{"type":"newline","loc":{"start":{"line":15,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":15,"column":3}}} +{"type":"tag","loc":{"start":{"line":15,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":15,"column":4}},"val":"p"} +{"type":"text","loc":{"start":{"line":15,"column":5},"filename":"/cases/code.conditionals.pug","end":{"line":15,"column":8}},"val":"bar"} +{"type":"newline","loc":{"start":{"line":16,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":16,"column":3}}} +{"type":"tag","loc":{"start":{"line":16,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":16,"column":4}},"val":"p"} +{"type":"text","loc":{"start":{"line":16,"column":5},"filename":"/cases/code.conditionals.pug","end":{"line":16,"column":8}},"val":"baz"} +{"type":"outdent","loc":{"start":{"line":17,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":17,"column":1}}} +{"type":"else","loc":{"start":{"line":17,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":17,"column":5}},"val":""} +{"type":"indent","loc":{"start":{"line":18,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":18,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":18,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":18,"column":4}},"val":"p"} +{"type":"text","loc":{"start":{"line":18,"column":5},"filename":"/cases/code.conditionals.pug","end":{"line":18,"column":8}},"val":"bar"} +{"type":"outdent","loc":{"start":{"line":20,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":20,"column":1}}} +{"type":"if","loc":{"start":{"line":20,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":20,"column":12}},"val":"!(true)"} +{"type":"indent","loc":{"start":{"line":21,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":21,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":21,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":21,"column":4}},"val":"p"} +{"type":"text","loc":{"start":{"line":21,"column":5},"filename":"/cases/code.conditionals.pug","end":{"line":21,"column":8}},"val":"foo"} +{"type":"outdent","loc":{"start":{"line":22,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":22,"column":1}}} +{"type":"else","loc":{"start":{"line":22,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":22,"column":5}},"val":""} +{"type":"indent","loc":{"start":{"line":23,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":23,"column":3}},"val":2} +{"type":"tag","loc":{"start":{"line":23,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":23,"column":4}},"val":"p"} +{"type":"text","loc":{"start":{"line":23,"column":5},"filename":"/cases/code.conditionals.pug","end":{"line":23,"column":8}},"val":"bar"} +{"type":"outdent","loc":{"start":{"line":25,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":25,"column":1}}} +{"type":"if","loc":{"start":{"line":25,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":25,"column":12}},"val":"'nested'"} +{"type":"indent","loc":{"start":{"line":26,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":26,"column":3}},"val":2} +{"type":"if","loc":{"start":{"line":26,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":26,"column":13}},"val":"'works'"} +{"type":"indent","loc":{"start":{"line":27,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":27,"column":5}},"val":4} +{"type":"tag","loc":{"start":{"line":27,"column":5},"filename":"/cases/code.conditionals.pug","end":{"line":27,"column":6}},"val":"p"} +{"type":"text","loc":{"start":{"line":27,"column":7},"filename":"/cases/code.conditionals.pug","end":{"line":27,"column":10}},"val":"yay"} +{"type":"outdent","loc":{"start":{"line":29,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":29,"column":1}}} +{"type":"outdent","loc":{"start":{"line":29,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":29,"column":1}}} +{"type":"comment","loc":{"start":{"line":29,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":29,"column":23}},"val":" allow empty blocks","buffer":false} +{"type":"newline","loc":{"start":{"line":30,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":30,"column":1}}} +{"type":"if","loc":{"start":{"line":30,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":30,"column":9}},"val":"false"} +{"type":"newline","loc":{"start":{"line":31,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":31,"column":1}}} +{"type":"else","loc":{"start":{"line":31,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":31,"column":5}},"val":""} +{"type":"indent","loc":{"start":{"line":32,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":32,"column":3}},"val":2} +{"type":"class","loc":{"start":{"line":32,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":32,"column":7}},"val":"bar"} +{"type":"outdent","loc":{"start":{"line":33,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":33,"column":1}}} +{"type":"if","loc":{"start":{"line":33,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":33,"column":8}},"val":"true"} +{"type":"indent","loc":{"start":{"line":34,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":34,"column":3}},"val":2} +{"type":"class","loc":{"start":{"line":34,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":34,"column":7}},"val":"bar"} +{"type":"outdent","loc":{"start":{"line":35,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":35,"column":1}}} +{"type":"else","loc":{"start":{"line":35,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":35,"column":5}},"val":""} +{"type":"newline","loc":{"start":{"line":36,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":36,"column":1}}} +{"type":"class","loc":{"start":{"line":36,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":36,"column":6}},"val":"bing"} +{"type":"newline","loc":{"start":{"line":38,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":38,"column":1}}} +{"type":"if","loc":{"start":{"line":38,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":38,"column":9}},"val":"false"} +{"type":"indent","loc":{"start":{"line":39,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":39,"column":3}},"val":2} +{"type":"class","loc":{"start":{"line":39,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":39,"column":8}},"val":"bing"} +{"type":"outdent","loc":{"start":{"line":40,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":40,"column":1}}} +{"type":"else-if","loc":{"start":{"line":40,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":40,"column":14}},"val":"false"} +{"type":"indent","loc":{"start":{"line":41,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":41,"column":3}},"val":2} +{"type":"class","loc":{"start":{"line":41,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":41,"column":7}},"val":"bar"} +{"type":"outdent","loc":{"start":{"line":42,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":42,"column":1}}} +{"type":"else","loc":{"start":{"line":42,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":42,"column":5}},"val":""} +{"type":"indent","loc":{"start":{"line":43,"column":1},"filename":"/cases/code.conditionals.pug","end":{"line":43,"column":3}},"val":2} +{"type":"class","loc":{"start":{"line":43,"column":3},"filename":"/cases/code.conditionals.pug","end":{"line":43,"column":7}},"val":"foo"} +{"type":"outdent","loc":{"start":{"line":43,"column":7},"filename":"/cases/code.conditionals.pug","end":{"line":43,"column":7}}} +{"type":"eos","loc":{"start":{"line":43,"column":7},"filename":"/cases/code.conditionals.pug","end":{"line":43,"column":7}}} \ No newline at end of file diff --git a/packages/pug-parser/test/cases/code.escape.tokens.json b/packages/pug-parser/test/cases/code.escape.tokens.json index 4aebd6658..45fee43f0 100644 --- a/packages/pug-parser/test/cases/code.escape.tokens.json +++ b/packages/pug-parser/test/cases/code.escape.tokens.json @@ -1,6 +1,6 @@ -{"type":"tag","line":1,"col":1,"val":"p"} -{"type":"code","line":1,"col":2,"val":"'