Switch to using plain text with no additional exit matcher added.
This commit is contained in:
		
							parent
							
								
									208e2cfe87
								
							
						
					
					
						commit
						f964481544
					
				| @ -26,11 +26,11 @@ use crate::parser::object_parser::standard_set_object; | ||||
| use crate::parser::parser_context::ContextElement; | ||||
| use crate::parser::parser_context::ExitMatcherNode; | ||||
| use crate::parser::parser_with_context::parser_with_context; | ||||
| use crate::parser::plain_text::plain_text; | ||||
| use crate::parser::util::blank_line; | ||||
| use crate::parser::util::exit_matcher_parser; | ||||
| use crate::parser::util::get_consumed; | ||||
| use crate::parser::util::start_of_line; | ||||
| use crate::parser::util::text_until_exit; | ||||
| 
 | ||||
| #[tracing::instrument(ret, level = "debug")] | ||||
| pub fn verse_block<'r, 's>( | ||||
| @ -102,9 +102,7 @@ pub fn comment_block<'r, 's>( | ||||
|         None => None, | ||||
|     }; | ||||
| 
 | ||||
|     let (remaining, contents) = map(parser_with_context!(plain_text)(&parser_context), |obj| { | ||||
|         obj.source | ||||
|     })(remaining)?; | ||||
|     let (remaining, contents) = parser_with_context!(text_until_exit)(&parser_context)(remaining)?; | ||||
|     let (remaining, _end) = lesser_block_end_specialized(&parser_context, remaining)?; | ||||
| 
 | ||||
|     let source = get_consumed(input, remaining); | ||||
| @ -140,9 +138,7 @@ pub fn example_block<'r, 's>( | ||||
|         None => None, | ||||
|     }; | ||||
| 
 | ||||
|     let (remaining, contents) = map(parser_with_context!(plain_text)(&parser_context), |obj| { | ||||
|         obj.source | ||||
|     })(remaining)?; | ||||
|     let (remaining, contents) = parser_with_context!(text_until_exit)(&parser_context)(remaining)?; | ||||
|     let (remaining, _end) = lesser_block_end_specialized(&parser_context, remaining)?; | ||||
| 
 | ||||
|     let source = get_consumed(input, remaining); | ||||
| @ -179,9 +175,7 @@ pub fn export_block<'r, 's>( | ||||
|         None => None, | ||||
|     }; | ||||
| 
 | ||||
|     let (remaining, contents) = map(parser_with_context!(plain_text)(&parser_context), |obj| { | ||||
|         obj.source | ||||
|     })(remaining)?; | ||||
|     let (remaining, contents) = parser_with_context!(text_until_exit)(&parser_context)(remaining)?; | ||||
|     let (remaining, _end) = lesser_block_end_specialized(&parser_context, remaining)?; | ||||
| 
 | ||||
|     let source = get_consumed(input, remaining); | ||||
| @ -215,9 +209,7 @@ pub fn src_block<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s st | ||||
|         None => None, | ||||
|     }; | ||||
| 
 | ||||
|     let (remaining, contents) = map(parser_with_context!(plain_text)(&parser_context), |obj| { | ||||
|         obj.source | ||||
|     })(remaining)?; | ||||
|     let (remaining, contents) = parser_with_context!(text_until_exit)(&parser_context)(remaining)?; | ||||
|     let (remaining, _end) = lesser_block_end_specialized(&parser_context, remaining)?; | ||||
| 
 | ||||
|     let source = get_consumed(input, remaining); | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| use nom::branch::alt; | ||||
| use nom::character::complete::anychar; | ||||
| use nom::character::complete::line_ending; | ||||
| use nom::character::complete::multispace0; | ||||
| use nom::character::complete::none_of; | ||||
| @ -8,7 +9,9 @@ use nom::combinator::not; | ||||
| use nom::combinator::opt; | ||||
| use nom::combinator::peek; | ||||
| use nom::combinator::recognize; | ||||
| use nom::combinator::verify; | ||||
| use nom::multi::many0; | ||||
| use nom::multi::many_till; | ||||
| use nom::sequence::tuple; | ||||
| 
 | ||||
| use super::parser_context::ContextElement; | ||||
| @ -203,6 +206,14 @@ pub fn whitespace_eof(input: &str) -> Res<&str, &str> { | ||||
|     recognize(tuple((multispace0, eof)))(input) | ||||
| } | ||||
| 
 | ||||
| #[tracing::instrument(ret, level = "debug")] | ||||
| pub fn text_until_exit<'r, 's>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> { | ||||
|     recognize(verify( | ||||
|         many_till(anychar, parser_with_context!(exit_matcher_parser)(context)), | ||||
|         |(children, _exit_contents)| !children.is_empty(), | ||||
|     ))(input) | ||||
| } | ||||
| 
 | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     use super::*; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander