Fix handling text-after-closing-brace and trailing command whitespace

This commit is contained in:
Tangent Wantwight 2023-08-04 15:52:26 -04:00
parent 0d469abffc
commit 61d967b6f1
2 changed files with 8 additions and 5 deletions

4
3x5.js
View file

@ -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\

View file

@ -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");