pug-parser
Advanced tools
Comparing version 3.0.1 to 4.0.0
95
index.js
@@ -257,2 +257,3 @@ 'use strict'; | ||
line: this.peek().line, | ||
col: this.peek().col, | ||
filename: this.filename | ||
@@ -290,2 +291,3 @@ }); | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -303,2 +305,3 @@ }); | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -310,3 +313,4 @@ }); | ||
var tok = this.advance(); | ||
if (this.peek().type === 'text') { | ||
var nextType = this.peek().type; | ||
if (nextType === 'text' || nextType === 'interpolated-code') { | ||
tags.push({ | ||
@@ -316,2 +320,3 @@ type: 'Text', | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -351,2 +356,3 @@ }); | ||
line: text.line, | ||
column: text.col, | ||
isHtml: true | ||
@@ -410,3 +416,9 @@ }; | ||
var tok = this.expect('case'); | ||
var node = {type: 'Case', expr: tok.val, line: tok.line, filename: this.filename}; | ||
var node = { | ||
type: 'Case', | ||
expr: tok.val, | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
}; | ||
@@ -454,2 +466,3 @@ var block = this.emptyBlock(tok.line + 1); | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -463,2 +476,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -481,2 +495,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -500,2 +515,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -529,2 +545,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -551,2 +568,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -577,2 +595,3 @@ } | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -596,3 +615,5 @@ }; | ||
parseBlockCode: function(){ | ||
var line = this.expect('blockcode').line; | ||
var tok = this.expect('blockcode'); | ||
var line = tok.line; | ||
var column = tok.col; | ||
var body = this.peek(); | ||
@@ -603,3 +624,3 @@ var text = ''; | ||
while (this.peek().type !== 'end-pipeless-text') { | ||
var tok = this.advance(); | ||
tok = this.advance(); | ||
switch (tok.type) { | ||
@@ -630,2 +651,3 @@ case 'text': | ||
line: line, | ||
column: column, | ||
filename: this.filename | ||
@@ -648,2 +670,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -657,2 +680,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -673,2 +697,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -691,2 +716,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -715,2 +741,3 @@ }; | ||
line: textToken.line, | ||
column: textToken.col, | ||
filename: this.filename | ||
@@ -731,2 +758,3 @@ } | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -749,2 +777,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -771,6 +800,8 @@ }; | ||
path: path.val.trim(), | ||
line: tok.line, | ||
line: path.line, | ||
column: path.col, | ||
filename: this.filename | ||
}, | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -792,2 +823,3 @@ }; | ||
node.line = tok.line; | ||
node.column = tok.col; | ||
@@ -802,3 +834,8 @@ return node; | ||
} | ||
return {type: 'MixinBlock', line: tok.line, filename: this.filename}; | ||
return { | ||
type: 'MixinBlock', | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
}; | ||
}, | ||
@@ -808,3 +845,8 @@ | ||
var tok = this.expect('yield'); | ||
return {type: 'YieldBlock', line: tok.line, filename: this.filename}; | ||
return { | ||
type: 'YieldBlock', | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
}; | ||
}, | ||
@@ -822,6 +864,6 @@ | ||
type: 'FileReference', | ||
line: tok.line, | ||
filename: this.filename | ||
}, | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -836,2 +878,4 @@ }; | ||
node.file.path = path.val.trim(); | ||
node.file.line = path.line; | ||
node.file.column = path.col; | ||
@@ -873,2 +917,3 @@ if ((/\.jade$/.test(node.file.path) || /\.pug$/.test(node.file.path)) && !filters.length) { | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -904,2 +949,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -926,6 +972,18 @@ }; | ||
case 'text': | ||
block.nodes.push({type: 'Text', val: tok.val, line: tok.line}); | ||
block.nodes.push({ | ||
type: 'Text', | ||
val: tok.val, | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
}); | ||
break; | ||
case 'newline': | ||
block.nodes.push({type: 'Text', val: '\n', line: tok.line}); | ||
block.nodes.push({ | ||
type: 'Text', | ||
val: '\n', | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
}); | ||
break; | ||
@@ -944,2 +1002,3 @@ case 'start-pug-interpolation': | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -998,2 +1057,3 @@ }); | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -1020,2 +1080,3 @@ }; | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
@@ -1051,2 +1112,5 @@ }; | ||
val: "'" + tok.val + "'", | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename, | ||
mustEscape: false | ||
@@ -1064,3 +1128,9 @@ }); | ||
var tok = this.advance(); | ||
tag.attributeBlocks.push(tok.val); | ||
tag.attributeBlocks.push({ | ||
type: 'AttributeBlock', | ||
val: tok.val, | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename | ||
}); | ||
break; | ||
@@ -1149,2 +1219,5 @@ default: | ||
val: tok.val, | ||
line: tok.line, | ||
column: tok.col, | ||
filename: this.filename, | ||
mustEscape: tok.mustEscape !== false | ||
@@ -1151,0 +1224,0 @@ }); |
{ | ||
"name": "pug-parser", | ||
"version": "3.0.1", | ||
"version": "4.0.0", | ||
"description": "The pug parser (takes an array of tokens and converts it to an abstract syntax tree)", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -59,2 +59,5 @@ # pug-parser | ||
"val": "\"bar\"", | ||
"line": 1, | ||
"column": 5, | ||
"filename": "my-file.pug", | ||
"mustEscape": true | ||
@@ -66,2 +69,3 @@ } | ||
"line": 1, | ||
"column": 1, | ||
"filename": "my-file.pug" | ||
@@ -68,0 +72,0 @@ } |
@@ -87,2 +87,6 @@ {"type":"tag","line":1,"col":1,"val":"option"} | ||
{"type":"end-pipeless-text","line":44,"col":4} | ||
{"type":"eos","line":44,"col":4} | ||
{"type":"newline","line":45,"col": 1} | ||
{"type":"text","line":45,"col": 3,"val":"foo"} | ||
{"type":"newline","line":46,"col": 1} | ||
{"type":"interpolated-code","line":46,"col":3,"val":"bar","mustEscape":true,"buffer":true} | ||
{"type":"eos","line":46,"col":9} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
750780
128
4085
91