Implement the new fields for verbatim and code.

This commit is contained in:
Tom Alexander
2023-12-08 16:04:18 -05:00
parent 8fd9ff3848
commit 9bcba4020d
2 changed files with 22 additions and 10 deletions

View File

@@ -162,13 +162,14 @@ fn verbatim<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Verbatim<'s>> {
let (remaining, contents) = text_markup_string("=")(context, input)?;
let (remaining, (contents, post_blank)) = text_markup_string("=")(context, input)?;
let source = get_consumed(input, remaining);
Ok((
remaining,
Verbatim {
source: source.into(),
contents: contents.into(),
post_blank: post_blank.map(Into::<&str>::into),
},
))
}
@@ -181,13 +182,14 @@ fn code<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Code<'s>> {
let (remaining, contents) = text_markup_string("~")(context, input)?;
let (remaining, (contents, post_blank)) = text_markup_string("~")(context, input)?;
let source = get_consumed(input, remaining);
Ok((
remaining,
Code {
source: source.into(),
contents: contents.into(),
post_blank: post_blank.map(Into::<&str>::into),
},
))
}
@@ -262,7 +264,7 @@ fn text_markup_string(
) -> impl for<'b, 'g, 'r, 's> Fn(
RefContext<'b, 'g, 'r, 's>,
OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>>
) -> Res<OrgSource<'s>, (OrgSource<'s>, Option<OrgSource<'s>>)>
+ '_ {
move |context, input: OrgSource<'_>| _text_markup_string(context, input, marker_symbol)
}
@@ -275,7 +277,7 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>(
context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>,
marker_symbol: &'c str,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
) -> Res<OrgSource<'s>, (OrgSource<'s>, Option<OrgSource<'s>>)> {
let (remaining, _) = pre(context, input)?;
let (remaining, open) = tag(marker_symbol)(remaining)?;
let (remaining, _peek_not_whitespace) =
@@ -308,9 +310,9 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>(
}
let (remaining, _close) = text_markup_end_specialized(context, remaining)?;
let (remaining, _trailing_whitespace) =
let (remaining, post_blank) =
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
Ok((remaining, contents))
Ok((remaining, (contents, post_blank)))
}
#[cfg_attr(