Add accessors for booleans on what we are allowed to match.
This commit is contained in:
parent
9d534aa627
commit
1d571acc17
@ -26,8 +26,8 @@ pub struct NomContext<'r> {
|
||||
parent: Option<&'r Self>,
|
||||
fail_matcher: ChainBehavior,
|
||||
/// You can't have nested bolds or links in org-mode
|
||||
can_match_bold: bool,
|
||||
can_match_link: bool,
|
||||
match_bold_allowed: bool,
|
||||
match_link_allowed: bool,
|
||||
}
|
||||
|
||||
impl<'r> NomContext<'r> {
|
||||
@ -35,8 +35,8 @@ impl<'r> NomContext<'r> {
|
||||
NomContext {
|
||||
parent: None,
|
||||
fail_matcher: ChainBehavior::IgnoreParent(Some(fail_matcher)),
|
||||
can_match_bold: true,
|
||||
can_match_link: true,
|
||||
match_bold_allowed: true,
|
||||
match_link_allowed: true,
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,14 +44,22 @@ impl<'r> NomContext<'r> {
|
||||
NomContext {
|
||||
parent: Some(&self),
|
||||
fail_matcher: ChainBehavior::AndParent(Some(other)),
|
||||
can_match_bold: self.can_match_bold,
|
||||
can_match_link: self.can_match_link,
|
||||
match_bold_allowed: self.match_bold_allowed,
|
||||
match_link_allowed: self.match_link_allowed,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn not_matching_fail<'s>(&self, i: &'s str) -> IResult<&'s str, (), VerboseError<&'s str>> {
|
||||
not(FailChecker::new(self))(i)
|
||||
}
|
||||
|
||||
pub fn can_match_bold(&self) -> bool {
|
||||
self.match_bold_allowed
|
||||
}
|
||||
|
||||
pub fn can_match_link(&self) -> bool {
|
||||
self.match_link_allowed
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> Parser<&'b str, &'b str, VerboseError<&'b str>> for FailChecker<'a> {
|
||||
|
Loading…
Reference in New Issue
Block a user