Fix matching only the specific markup.

This commit is contained in:
Tom Alexander 2023-04-22 21:01:29 -04:00
parent e6c5670a85
commit 62c226fb47
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -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<Object<'s>>> {
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> {