From 61d967b6f1c0ae02cc988a0d6513b3bb030ed09e Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Fri, 4 Aug 2023 15:52:26 -0400 Subject: [PATCH] Fix handling text-after-closing-brace and trailing command whitespace --- 3x5.js | 4 ++-- notcl.js | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/3x5.js b/3x5.js index 0b1c382..16b29dc 100644 --- a/3x5.js +++ b/3x5.js @@ -55,10 +55,10 @@ let theCard = { Is this markdown-parsed? - [button "No we want to render UI" {noop}] + [button "No we want to render UI" \\{noop}] } { Since we want escapes to work, these blocks [i will] be subject to substitutions. - } + } # A comment para { line endings escaped\ diff --git a/notcl.js b/notcl.js index 38ee7fb..ca02212 100644 --- a/notcl.js +++ b/notcl.js @@ -35,8 +35,8 @@ var Notcl = (() => { Regex(/\}/y).expects("}") ).map(([_left, fragments, _right]) => fragments.join("")); const Word = Choose( - Brace.map((text) => ({ text })), - BasicWord + BasicWord, + Brace.map((text) => ({ text })) ); const CommandTerminator = Choose( @@ -54,7 +54,10 @@ var Notcl = (() => { 0, Sequence(PreWordWhitespace, Word).map(([_padding, word]) => word) ), - Choose(Sequence(PreWordWhitespace, Word), CommandTerminator) + Choose( + Sequence(PreWordWhitespace, Word).expects("whitespace"), + Sequence(AtLeast(0, PreWordWhitespace), CommandTerminator).expects(";") + ) ).map(([word, moreWords, _end]) => [word].concat(moreWords)) ).expects("COMMAND");