Closed nacro90 closed 1 year ago
The reason this doesn't work for the whitespace before the closing is that char("*").neg().plus()
reads over the whitespace and to right before the asterisk. You can fix this like so:
final parser = seq3(
char("*"),
seq2(
whitespace().not(),
[seq2(whitespace(), char('*')), char('*')]
.toChoiceParser()
.neg()
.plus(),
).flatten(),
char("*"),
);
Easier and maybe closer to what you want is the following:
final parser = seq3(
char("*"),
char('*').neg().plus().flatten(),
char("*"),
).where((sequence) => sequence.second.trim() == sequence.second);
Thank you so much :hearts:
Hi, thanks for awesome library.
I have a problem with the parsing. I couldn't be sure if the behavior is wanted or not.
The parser code supposed to parse bold text format, which means surrounding by
*
without preceding or succeeding whitespace.For this parser code, I wrote two tests for preceding and succeeding. Preceding works as expected but succeeding parses the input as
['*', 'invalid ', '*']
with following whitespace included. How can I avoid the parser not to parse the whitespace? I triedwhitespace().neg() instead of
not()but then it parses
''and it can not parse the correct bold text like
boldbecause of negation of whitespace parses and consumes the
`.Working:
Not working: