Move the paragraph context into the paragraph parser.
This commit is contained in:
		
							parent
							
								
									c312673f12
								
							
						
					
					
						commit
						185c761a5d
					
				| @ -130,12 +130,14 @@ pub fn link_end(input: &str) -> Res<&str, TextElement> { | ||||
| } | ||||
| 
 | ||||
| pub fn paragraph_end(input: &str) -> Res<&str, &str> { | ||||
|     recognize(tuple((map(line_break, TextElement::LineBreak), blank_line)))(input) | ||||
|     recognize(tuple(( | ||||
|         map(line_break, TextElement::LineBreak), | ||||
|         many1(blank_line), | ||||
|     )))(input) | ||||
| } | ||||
| 
 | ||||
| pub fn document(input: &str) -> Res<&str, Vec<(Vec<TextElement>, &str)>> { | ||||
|     let initial_context = ContextTree::new(); | ||||
|     let paragraph_context = initial_context.with_additional_fail_matcher(¶graph_end); | ||||
|     let ret = many1(parser_with_context!(paragraph)(¶graph_context))(input); | ||||
|     let ret = many1(parser_with_context!(paragraph)(&initial_context))(input); | ||||
|     ret | ||||
| } | ||||
|  | ||||
| @ -84,6 +84,8 @@ pub fn paragraph<'s, 'r>( | ||||
|     i: &'s str, | ||||
|     context: &'r OrgModeContext<'r>, | ||||
| ) -> Res<&'s str, (Vec<TextElement<'s>>, &'s str)> { | ||||
|     let text_element_parser = parser_with_context!(flat_text_element)(context); | ||||
|     many_till(text_element_parser, paragraph_end)(i) | ||||
|     let paragraph_context = context.with_additional_fail_matcher(¶graph_end); | ||||
|     let text_element_parser = parser_with_context!(flat_text_element)(¶graph_context); | ||||
|     let ret = many_till(text_element_parser, paragraph_end)(i); | ||||
|     ret | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander