From d9749da99fdb68cb9c3706b71d93199c398e6fc7 Mon Sep 17 00:00:00 2001 From: Ben Ashton Date: Mon, 5 Sep 2022 19:11:11 -0600 Subject: [PATCH] Allow empty comments --- src/token_stream.mjs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/token_stream.mjs b/src/token_stream.mjs index cf29413..4318979 100644 --- a/src/token_stream.mjs +++ b/src/token_stream.mjs @@ -2,6 +2,7 @@ import { CharacterStream } from './character_stream.mjs'; import { TemplateSyntaxError } from './errors/template_syntax_error.mjs'; export class TokenStream { + static ESCAPE = '\\'; static OPEN_INLINE = '<%'; static CLOSE_INLINE = '%>'; static OPEN_INLINE_UNESCAPED = ' /\S/.test(c)); } else if (this._cs.isNext(TokenStream.OPEN_INLINE)) { return flushRaw() || this._readInline(); } else if (this._cs.isNext(TokenStream.OPEN_INLINE_UNESCAPED)) { @@ -174,13 +180,13 @@ export class TokenStream { // Skip tag this._cs.next(tag.length); - // Check for mandatory space - if (this._cs.peek() !== ' ') { + // Check for mandatory space/tab/new line + if (this._isSpace(this._cs.peek())) { + // Consume space + this._cs.next(); + } else if (/[^\r\n]/.test(this._cs.peek())) { this._missingFullLineSpaceError(tag); } - - // Consume space - this._cs.next(); // Remainder of line is value const value = this._cs.nextWhile((c) => c !== '\n');