diff --git a/magnetar_mmm_parser/src/lib.rs b/magnetar_mmm_parser/src/lib.rs index ee70239..48a9e17 100644 --- a/magnetar_mmm_parser/src/lib.rs +++ b/magnetar_mmm_parser/src/lib.rs @@ -195,6 +195,7 @@ fn space(input: Span) -> IResult { struct Context; impl Context { + #[inline] const fn partial<'a>( &self, func: impl Fn(&Self, Span<'a>) -> IResult, Token<'a>> + 'static, @@ -278,22 +279,25 @@ impl Context { } fn tag_block_math<'a>(&self, input: Span<'a>) -> IResult, Token<'a>> { + let start = &tag("\\["); + let end = &tag("\\]"); + let (input, _) = opt(line_ending)(input)?; if input.get_column() != 0 { return fail(input); } - let (input, _) = tag("\\[")(input)?; + let (input, _) = start(input)?; let (input, _) = opt(line_ending)(input)?; let (input, math_span) = recognize(many1_count(tuple(( - not(tuple((opt(line_ending), tag("\\]")))), + not(tuple((opt(line_ending), end))), not_line_ending, ))))(input)?; let (input, _) = opt(line_ending)(input)?; - let (input, _) = tag("\\]")(input)?; + let (input, _) = end(input)?; let (input, _) = many0(space)(input)?; let (input, _) = not(not_line_ending)(input)?; let (input, _) = opt(line_ending)(input)?;