From 62c226fb478fec1d5844c94fe9fc153ead7f2e9f Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 22 Apr 2023 21:01:29 -0400 Subject: [PATCH] Fix matching only the specific markup. --- src/parser/text_markup.rs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/parser/text_markup.rs b/src/parser/text_markup.rs index b8e24c7..db3ce05 100644 --- a/src/parser/text_markup.rs +++ b/src/parser/text_markup.rs @@ -83,7 +83,7 @@ pub fn strike_through<'r, 's>( #[tracing::instrument(ret, level = "debug")] pub fn verbatim<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Verbatim<'s>> { - let text_markup_string_specialized = text_markup_string("+"); + let text_markup_string_specialized = text_markup_string("="); let (remaining, contents) = text_markup_string_specialized(context, input)?; let source = get_consumed(input, remaining); Ok((remaining, Verbatim { source, contents })) @@ -91,7 +91,7 @@ pub fn verbatim<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str #[tracing::instrument(ret, level = "debug")] pub fn code<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, Code<'s>> { - let text_markup_string_specialized = text_markup_string("+"); + let text_markup_string_specialized = text_markup_string("~"); let (remaining, contents) = text_markup_string_specialized(context, input)?; let source = get_consumed(input, remaining); Ok((remaining, Code { source, contents })) @@ -111,7 +111,7 @@ fn _text_markup_object<'r, 's, 'x>( marker_symbol: &'x str, ) -> Res<&'s str, Vec>> { let (remaining, _) = pre(context, input)?; - let (remaining, open) = marker(remaining)?; + let (remaining, open) = tag(marker_symbol)(remaining)?; let text_markup_end_specialized = text_markup_end(open); let parser_context = context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -147,7 +147,7 @@ fn _text_markup_string<'r, 's, 'x>( marker_symbol: &'x str, ) -> Res<&'s str, &'s str> { let (remaining, _) = pre(context, input)?; - let (remaining, open) = marker(remaining)?; + let (remaining, open) = tag(marker_symbol)(remaining)?; let text_markup_end_specialized = text_markup_end(open); let parser_context = context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode { @@ -195,11 +195,6 @@ pub fn post<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, () Ok((remaining, ())) } -#[tracing::instrument(ret, level = "debug")] -pub fn marker(input: &str) -> Res<&str, &str> { - alt((tag("*"), tag("/"), tag("_"), tag("="), tag("~"), tag("+")))(input) -} - fn text_markup_end( marker_symbol: &str, ) -> impl for<'r, 's> Fn(Context<'r, 's>, &'s str) -> Res<&'s str, &'s str> {