From bd228dda26b6829105cb2c9a6b5962d656ba45bd Mon Sep 17 00:00:00 2001 From: "Amy J. Ko" Date: Tue, 2 Jul 2024 20:47:03 -0700 Subject: [PATCH] Fixed #509 parsing regression from infinite loop fixes. --- CHANGELOG.md | 6 ++++++ src/parser/Tokens.ts | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d688db97d..a3810c945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ We'll note all notable changes in this file, including bug fixes, enhancements, and all closed issues. Dates are in `YYYY-MM-DD` format and versions are in [semantic versioning](http://semver.org/) format. +## 0.10.3 2024-07-07 + +### Fixed + +- [#509](https://github.com/wordplaydev/wordplay/issues/509) Fixed parsing regression from infinite loop fixes. + ## 0.10.2 2024-06-29 ### Fixed diff --git a/src/parser/Tokens.ts b/src/parser/Tokens.ts index 3c8d7bdf2..8c08db146 100644 --- a/src/parser/Tokens.ts +++ b/src/parser/Tokens.ts @@ -186,16 +186,19 @@ export default class Tokens { /** Used to read the remainder of a line, unless there are no more tokens, or we reach the end of a code example. */ readLine() { const nodes: Token[] = []; + let onFirst = true; if (!this.hasNext()) return nodes; - // Read at least one token, then keep going until we reach a token with a line break. + // If there are more tokens, and and it's not the end of a code block in markup, and we're either on the first token, or the next token has a line break, read another token. this.untilDo( () => this.hasNext() && - this.nextHasPrecedingLineBreak() === false && + (onFirst === true || + this.nextHasPrecedingLineBreak() === false) && this.nextIsnt(Sym.Code), () => { const next = this.read(); + onFirst = false; nodes.push(next); }, );