Give global options their own lifetime.
This commit is contained in:
@@ -21,6 +21,7 @@ use super::radio_link::RematchObject;
|
||||
use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting;
|
||||
use crate::context::parser_with_context;
|
||||
use crate::context::ContextElement;
|
||||
use crate::context::ContextMatcher;
|
||||
use crate::context::ExitClass;
|
||||
use crate::context::ExitMatcherNode;
|
||||
use crate::context::RefContext;
|
||||
@@ -40,8 +41,8 @@ use crate::types::Underline;
|
||||
use crate::types::Verbatim;
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn text_markup<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
pub fn text_markup<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Object<'s>> {
|
||||
alt((
|
||||
@@ -58,8 +59,8 @@ pub fn text_markup<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn bold<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
pub fn bold<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Bold<'s>> {
|
||||
let text_markup_object_specialized = text_markup_object("*");
|
||||
@@ -75,8 +76,8 @@ pub fn bold<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn italic<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
pub fn italic<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Italic<'s>> {
|
||||
let text_markup_object_specialized = text_markup_object("/");
|
||||
@@ -92,8 +93,8 @@ pub fn italic<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn underline<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
pub fn underline<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Underline<'s>> {
|
||||
let text_markup_object_specialized = text_markup_object("_");
|
||||
@@ -109,8 +110,8 @@ pub fn underline<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn strike_through<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
pub fn strike_through<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, StrikeThrough<'s>> {
|
||||
let text_markup_object_specialized = text_markup_object("+");
|
||||
@@ -126,8 +127,8 @@ pub fn strike_through<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn verbatim<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
pub fn verbatim<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Verbatim<'s>> {
|
||||
let text_markup_string_specialized = text_markup_string("=");
|
||||
@@ -143,8 +144,8 @@ pub fn verbatim<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn code<'r, 's>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
pub fn code<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Code<'s>> {
|
||||
let text_markup_string_specialized = text_markup_string("~");
|
||||
@@ -161,8 +162,8 @@ pub fn code<'r, 's>(
|
||||
|
||||
fn text_markup_object<'c>(
|
||||
marker_symbol: &'c str,
|
||||
) -> impl for<'b, 'r, 's> Fn(
|
||||
RefContext<'b, 'r, 's>,
|
||||
) -> impl for<'b, 'g, 'r, 's> Fn(
|
||||
RefContext<'b, 'g, 'r, 's>,
|
||||
OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Vec<Object<'s>>>
|
||||
+ 'c {
|
||||
@@ -171,10 +172,10 @@ fn text_markup_object<'c>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn _text_markup_object<'r, 's, 'x>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
fn _text_markup_object<'b, 'g, 'r, 's, 'c>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
marker_symbol: &'x str,
|
||||
marker_symbol: &'c str,
|
||||
) -> Res<OrgSource<'s>, Vec<Object<'s>>> {
|
||||
let (remaining, _) = pre(context, input)?;
|
||||
let (remaining, open) = tag(marker_symbol)(remaining)?;
|
||||
@@ -214,8 +215,8 @@ fn _text_markup_object<'r, 's, 'x>(
|
||||
|
||||
fn text_markup_string<'c>(
|
||||
marker_symbol: &'c str,
|
||||
) -> impl for<'b, 'r, 's> Fn(
|
||||
RefContext<'b, 'r, 's>,
|
||||
) -> impl for<'b, 'g, 'r, 's> Fn(
|
||||
RefContext<'b, 'g, 'r, 's>,
|
||||
OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>>
|
||||
+ 'c {
|
||||
@@ -223,10 +224,10 @@ fn text_markup_string<'c>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn _text_markup_string<'r, 's, 'x>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
fn _text_markup_string<'b, 'g, 'r, 's, 'c>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
marker_symbol: &'x str,
|
||||
marker_symbol: &'c str,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
let (remaining, _) = pre(context, input)?;
|
||||
let (remaining, open) = tag(marker_symbol)(remaining)?;
|
||||
@@ -265,8 +266,8 @@ fn _text_markup_string<'r, 's, 'x>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn pre<'r, 's>(
|
||||
_context: RefContext<'_, 'r, 's>,
|
||||
pub fn pre<'b, 'g, 'r, 's>(
|
||||
_context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, ()> {
|
||||
let preceding_character = input.get_preceding_character();
|
||||
@@ -285,26 +286,23 @@ pub fn pre<'r, 's>(
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn post<'r, 's>(
|
||||
_context: RefContext<'_, 'r, 's>,
|
||||
pub fn post<'b, 'g, 'r, 's>(
|
||||
_context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, ()> {
|
||||
let (remaining, _) = alt((recognize(one_of(" \r\n\t-.,;:!?')}[\"")), line_ending))(input)?;
|
||||
Ok((remaining, ()))
|
||||
}
|
||||
|
||||
fn text_markup_end<'c>(
|
||||
marker_symbol: &'c str,
|
||||
) -> impl for<'r, 's> Fn(RefContext<'_, 'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> + 'c
|
||||
{
|
||||
fn text_markup_end<'c>(marker_symbol: &'c str) -> impl ContextMatcher + 'c {
|
||||
move |context, input: OrgSource<'_>| _text_markup_end(context, input, marker_symbol)
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn _text_markup_end<'r, 's, 'x>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
fn _text_markup_end<'b, 'g, 'r, 's, 'c>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
marker_symbol: &'x str,
|
||||
marker_symbol: &'c str,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
not(preceded_by_whitespace)(input)?;
|
||||
let (remaining, _marker) = terminated(
|
||||
@@ -317,9 +315,9 @@ fn _text_markup_end<'r, 's, 'x>(
|
||||
|
||||
impl<'x> RematchObject<'x> for Bold<'x> {
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn rematch_object<'r, 's>(
|
||||
fn rematch_object<'b, 'g, 'r, 's>(
|
||||
&'x self,
|
||||
_context: RefContext<'_, 'r, 's>,
|
||||
_context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Object<'s>> {
|
||||
let (remaining, children) =
|
||||
@@ -336,8 +334,8 @@ impl<'x> RematchObject<'x> for Bold<'x> {
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
fn _rematch_text_markup_object<'r, 's, 'x>(
|
||||
context: RefContext<'_, 'r, 's>,
|
||||
fn _rematch_text_markup_object<'b, 'g, 'r, 's, 'x>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
marker_symbol: &'static str,
|
||||
original_match_children: &'x Vec<Object<'x>>,
|
||||
|
||||
Reference in New Issue
Block a user