chore(release): 7.1.0 [skip ci]

# [7.1.0](https://github.com/harttle/liquidjs/compare/v7.0.2...v7.1.0) (2019-02-20)

### Features

* throw an Error if delimiter not matched ([c33d8f6](https://github.com/harttle/liquidjs/commit/c33d8f6))
This commit is contained in:
semantic-release-bot
2019-02-20 14:45:44 +00:00
parent c33d8f6828
commit d7d00421e2
11 changed files with 71 additions and 40 deletions
+28 -16
View File
@@ -1,5 +1,5 @@
/*
* liquidjs@7.0.2, https://github.com/harttle/liquidjs
* liquidjs@7.1.0, https://github.com/harttle/liquidjs
* (c) 2016-2019 harttle
* Released under the MIT License.
*/
@@ -312,7 +312,6 @@ function captureStack() {
var LiquidError = /** @class */ (function () {
function LiquidError(err, token) {
this.input = token.input;
this.line = token.line;
this.file = token.file;
this.originalError = err;
this.token = token;
@@ -321,7 +320,7 @@ var LiquidError = /** @class */ (function () {
this.name = obj.constructor.name;
captureStack.call(obj);
var err = this.originalError;
var context = mkContext(this.input, this.line);
var context = mkContext(this.input, this.token.line);
this.message = mkMessage(err.message, this.token);
this.stack = this.message + '\n' + context +
'\n' + (this.stack || this.message) +
@@ -402,7 +401,7 @@ function mkMessage(msg, token) {
msg += ', file:' + token.file;
}
if (token.line) {
msg += ', line:' + token.line;
msg += ", line:" + token.line + ", col:" + token.col;
}
return msg;
}
@@ -718,7 +717,8 @@ function trimRight(token, greedy) {
}
var Token = /** @class */ (function () {
function Token(raw, pos, input, file, line) {
function Token(raw, col, input, file, line) {
this.col = col;
this.line = line;
this.raw = raw;
this.input = input;
@@ -790,20 +790,25 @@ var Tokenizer = /** @class */ (function () {
Tokenizer.prototype.tokenize = function (input, file) {
var tokens = [];
var p = 0;
var line = 1;
var curLine = 1;
var state = ParseState.HTML;
var buffer = '';
var bufferBegin = 0;
var lineBegin = 0;
var line = 1;
var col = 1;
while (p < input.length) {
if (input[p] === '\n')
line++;
if (input[p] === '\n') {
curLine++;
lineBegin = p + 1;
}
var bin = input.substr(p, 2);
if (state === ParseState.HTML) {
if (bin === '{{' || bin === '{%') {
if (buffer)
tokens.push(new HTMLToken(buffer, bufferBegin, input, file, line));
tokens.push(new HTMLToken(buffer, col, input, file, line));
buffer = bin;
bufferBegin = p;
line = curLine;
col = p - lineBegin + 1;
p += 2;
state = bin === '{{' ? ParseState.OUTPUT : ParseState.TAG;
continue;
@@ -811,26 +816,33 @@ var Tokenizer = /** @class */ (function () {
}
else if (state === ParseState.OUTPUT && bin === '}}') {
buffer += '}}';
tokens.push(new OutputToken(buffer, bufferBegin, input, file, line));
tokens.push(new OutputToken(buffer, col, input, file, line));
p += 2;
buffer = '';
bufferBegin = p;
line = curLine;
col = p - lineBegin + 1;
state = ParseState.HTML;
continue;
}
else if (bin === '%}') {
buffer += '%}';
tokens.push(new TagToken(buffer, bufferBegin, input, file, line));
tokens.push(new TagToken(buffer, col, input, file, line));
p += 2;
buffer = '';
bufferBegin = p;
line = curLine;
col = p - lineBegin + 1;
state = ParseState.HTML;
continue;
}
buffer += input[p++];
}
if (state !== ParseState.HTML) {
var t = state === ParseState.OUTPUT ? 'output' : 'tag';
var str = buffer.length > 16 ? buffer.slice(0, 13) + '...' : buffer;
throw new TokenizationError(new Error(t + " \"" + str + "\" not closed"), new Token(buffer, col, input, file, line));
}
if (buffer)
tokens.push(new HTMLToken(buffer, bufferBegin, input, file, line));
tokens.push(new HTMLToken(buffer, col, input, file, line));
whiteSpaceCtrl(tokens, this.options);
return tokens;
};
+1 -1
View File
File diff suppressed because one or more lines are too long
+28 -16
View File
@@ -1,5 +1,5 @@
/*
* liquidjs@7.0.2, https://github.com/harttle/liquidjs
* liquidjs@7.1.0, https://github.com/harttle/liquidjs
* (c) 2016-2019 harttle
* Released under the MIT License.
*/
@@ -300,7 +300,6 @@
var LiquidError = /** @class */ (function () {
function LiquidError(err, token) {
this.input = token.input;
this.line = token.line;
this.file = token.file;
this.originalError = err;
this.token = token;
@@ -309,7 +308,7 @@
this.name = obj.constructor.name;
captureStack.call(obj);
var err = this.originalError;
var context = mkContext(this.input, this.line);
var context = mkContext(this.input, this.token.line);
this.message = mkMessage(err.message, this.token);
this.stack = this.message + '\n' + context +
'\n' + (this.stack || this.message) +
@@ -390,7 +389,7 @@
msg += ', file:' + token.file;
}
if (token.line) {
msg += ', line:' + token.line;
msg += ", line:" + token.line + ", col:" + token.col;
}
return msg;
}
@@ -743,7 +742,8 @@
}
var Token = /** @class */ (function () {
function Token(raw, pos, input, file, line) {
function Token(raw, col, input, file, line) {
this.col = col;
this.line = line;
this.raw = raw;
this.input = input;
@@ -815,20 +815,25 @@
Tokenizer.prototype.tokenize = function (input, file) {
var tokens = [];
var p = 0;
var line = 1;
var curLine = 1;
var state = ParseState.HTML;
var buffer = '';
var bufferBegin = 0;
var lineBegin = 0;
var line = 1;
var col = 1;
while (p < input.length) {
if (input[p] === '\n')
line++;
if (input[p] === '\n') {
curLine++;
lineBegin = p + 1;
}
var bin = input.substr(p, 2);
if (state === ParseState.HTML) {
if (bin === '{{' || bin === '{%') {
if (buffer)
tokens.push(new HTMLToken(buffer, bufferBegin, input, file, line));
tokens.push(new HTMLToken(buffer, col, input, file, line));
buffer = bin;
bufferBegin = p;
line = curLine;
col = p - lineBegin + 1;
p += 2;
state = bin === '{{' ? ParseState.OUTPUT : ParseState.TAG;
continue;
@@ -836,26 +841,33 @@
}
else if (state === ParseState.OUTPUT && bin === '}}') {
buffer += '}}';
tokens.push(new OutputToken(buffer, bufferBegin, input, file, line));
tokens.push(new OutputToken(buffer, col, input, file, line));
p += 2;
buffer = '';
bufferBegin = p;
line = curLine;
col = p - lineBegin + 1;
state = ParseState.HTML;
continue;
}
else if (bin === '%}') {
buffer += '%}';
tokens.push(new TagToken(buffer, bufferBegin, input, file, line));
tokens.push(new TagToken(buffer, col, input, file, line));
p += 2;
buffer = '';
bufferBegin = p;
line = curLine;
col = p - lineBegin + 1;
state = ParseState.HTML;
continue;
}
buffer += input[p++];
}
if (state !== ParseState.HTML) {
var t = state === ParseState.OUTPUT ? 'output' : 'tag';
var str = buffer.length > 16 ? buffer.slice(0, 13) + '...' : buffer;
throw new TokenizationError(new Error(t + " \"" + str + "\" not closed"), new Token(buffer, col, input, file, line));
}
if (buffer)
tokens.push(new HTMLToken(buffer, bufferBegin, input, file, line));
tokens.push(new HTMLToken(buffer, col, input, file, line));
whiteSpaceCtrl(tokens, this.options);
return tokens;
};
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+2 -1
View File
@@ -1,9 +1,10 @@
export default class Token {
type: string;
line: number;
col: number;
raw: string;
input: string;
file: string;
value: string;
constructor(raw: any, pos: any, input: any, file: any, line: any);
constructor(raw: any, col: any, input: any, file: any, line: any);
}
-1
View File
@@ -2,7 +2,6 @@ declare abstract class LiquidError {
name: string;
message: string;
stack: string;
private line;
private file;
private input;
private token;