Implement rematch for plain text.
This commit is contained in:
parent
397083c658
commit
22bb42882b
@ -1,12 +1,16 @@
|
||||
use nom::branch::alt;
|
||||
use nom::bytes::complete::tag;
|
||||
use nom::character::complete::anychar;
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::peek;
|
||||
use nom::combinator::recognize;
|
||||
use nom::combinator::verify;
|
||||
use nom::multi::many_till;
|
||||
|
||||
use super::object::PlainText;
|
||||
use super::radio_link::RematchObject;
|
||||
use super::Context;
|
||||
use super::Object;
|
||||
use crate::error::Res;
|
||||
use crate::parser::object_parser::any_object_except_plain_text;
|
||||
use crate::parser::parser_with_context::parser_with_context;
|
||||
@ -33,12 +37,23 @@ fn plain_text_end<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s s
|
||||
recognize(parser_with_context!(any_object_except_plain_text)(context))(input)
|
||||
}
|
||||
|
||||
impl<'x> RematchObject for PlainText<'x> {
|
||||
fn rematch_object<'r, 's>(
|
||||
&self,
|
||||
_context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, Object<'s>> {
|
||||
map(tag(self.source), |s| {
|
||||
Object::PlainText(PlainText { source: s })
|
||||
})(input)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use nom::combinator::map;
|
||||
|
||||
use super::*;
|
||||
use crate::parser::object::Object;
|
||||
use crate::parser::parser_context::ContextElement;
|
||||
use crate::parser::parser_context::ContextTree;
|
||||
use crate::parser::parser_with_context::parser_with_context;
|
||||
|
Loading…
Reference in New Issue
Block a user