Add a detect object function similar to the detect element function.
This commit is contained in:
@@ -30,6 +30,19 @@ use crate::types::Object;
|
||||
use crate::types::Subscript;
|
||||
use crate::types::Superscript;
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn detect_subscript_or_superscript<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
|
||||
// This does not have to detect all valid subscript/superscript but all that it detects must be valid.
|
||||
let (remaining, _) = one_of("_^")(input)?;
|
||||
pre(input)?;
|
||||
if tag::<_, _, CustomError<_>>("*")(remaining).is_ok() {
|
||||
return Ok((input, ()));
|
||||
}
|
||||
let (remaining, _) = opt(one_of("+-"))(remaining)?;
|
||||
let (_remaining, _) = verify(anychar, |c| c.is_alphanumeric())(remaining)?;
|
||||
Ok((input, ()))
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||
pub fn subscript<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
|
||||
Reference in New Issue
Block a user