fix: escaping in argument and multiline text

This commit is contained in:
Artemy Egorov 2024-08-12 18:21:25 +03:00
parent e4eca62e38
commit 6099dbd236
2 changed files with 5 additions and 5 deletions

View file

@ -86,7 +86,7 @@ fn symbol<'src>() -> impl Parser<'src, &'src str, Token<'src>, extra::Err<Rich<'
fn argument<'src>() -> impl Parser<'src, &'src str, Token<'src>, extra::Err<Rich<'src, char, Span>>>
{
let arg_escape = just('\\')
.ignore_then(just('"'))
.ignore_then(choice((just('"'), just('\\'))))
.labelled("Escape sequence for argument");
let number = text::int(10)
@ -109,7 +109,7 @@ fn argument<'src>() -> impl Parser<'src, &'src str, Token<'src>, extra::Err<Rich
fn textual<'src>() -> impl Parser<'src, &'src str, Token<'src>, extra::Err<Rich<'src, char, Span>>>
{
let escape = just('\\')
.ignore_then(just('}'))
.ignore_then(choice((just('}'), just('\\'))))
.labelled("Multi-line escape sequence");
let text = none_of("\n")

View file

@ -31,9 +31,9 @@ pub fn tag<'tokens, 'src: 'tokens>(
let text_body = select! {
Token::TextBody(t) => t.to_owned(),
Token::MLText(t) => trim_indent(t).to_owned(),
Token::MLMSText(n, t) => set_spaces(t, n).to_owned(),
Token::MLRText(t) => t.to_owned()
Token::MLText(t) => trim_indent(t).replace("\\}", "}").replace("\\\\", "\\"),
Token::MLMSText(n, t) => set_spaces(t, n).replace("\\}", "}").replace("\\\\", "\\"),
Token::MLRText(t) => t.replace("\\}", "}").replace("\\\\", "\\")
}
.labelled("Text body");