When re-parsing last item in list, only disable white space consumption for last element in item.
This commit is contained in:
		
							parent
							
								
									b5f0521b56
								
							
						
					
					
						commit
						bfc9e7f58d
					
				| @ -0,0 +1,2 @@ | ||||
| - foo | ||||
| 
 | ||||
| @ -69,6 +69,7 @@ pub fn plain_list<'r, 's>( | ||||
| ) -> Res<OrgSource<'s>, PlainList<'s>> { | ||||
|     let parser_context = context | ||||
|         .with_additional_node(ContextElement::Context("plain list")) | ||||
|         .with_additional_node(ContextElement::ConsumeTrailingWhitespace(true)) | ||||
|         .with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode { | ||||
|             class: ExitClass::Beta, | ||||
|             exit_matcher: &plain_list_end, | ||||
| @ -175,14 +176,23 @@ pub fn plain_list_item<'r, 's>( | ||||
|             exit_matcher: &exit_matcher, | ||||
|         })); | ||||
| 
 | ||||
|     let (remaining, (children, _exit_contents)) = many_till( | ||||
|         parser_with_context!(element(true))(&parser_context), | ||||
|         alt(( | ||||
|             peek(recognize(tuple((start_of_line, many0(blank_line), eof)))), | ||||
|             parser_with_context!(exit_matcher_parser)(&parser_context), | ||||
|         )), | ||||
|     let (mut remaining, (mut children, _exit_contents)) = many_till( | ||||
|         include_input(parser_with_context!(element(true))(&parser_context)), | ||||
|         parser_with_context!(exit_matcher_parser)(&parser_context), | ||||
|     )(remaining)?; | ||||
| 
 | ||||
|     if !children.is_empty() && !context.should_consume_trailing_whitespace() { | ||||
|         let final_item_context = | ||||
|             parser_context.with_additional_node(ContextElement::ConsumeTrailingWhitespace(false)); | ||||
|         let (final_child_start, _original_final_child) = children.pop().expect("if-statement already checked that children was non-empty."); | ||||
|         let (remain, reparsed_final_element) = | ||||
|             include_input(parser_with_context!(element(true))(&final_item_context))( | ||||
|                 final_child_start, | ||||
|             )?; | ||||
|         remaining = remain; | ||||
|         children.push(reparsed_final_element); | ||||
|     } | ||||
| 
 | ||||
|     let (remaining, _trailing_ws) = | ||||
|         maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?; | ||||
| 
 | ||||
| @ -196,11 +206,23 @@ pub fn plain_list_item<'r, 's>( | ||||
|             tag: maybe_tag | ||||
|                 .map(|(_ws, item_tag, _divider)| item_tag) | ||||
|                 .unwrap_or(Vec::new()), | ||||
|             children, | ||||
|             children: children.into_iter().map(|(_start, item)| item).collect(), | ||||
|         }, | ||||
|     )); | ||||
| } | ||||
| 
 | ||||
| fn include_input<'s, F, O>( | ||||
|     mut inner: F, | ||||
| ) -> impl FnMut(OrgSource<'s>) -> Res<OrgSource<'s>, (OrgSource<'s>, O)> | ||||
| where | ||||
|     F: FnMut(OrgSource<'s>) -> Res<OrgSource<'s>, O>, | ||||
| { | ||||
|     move |input: OrgSource<'_>| { | ||||
|         let (remaining, output) = inner(input)?; | ||||
|         Ok((remaining, (input, output))) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] | ||||
| fn bullet<'s>(i: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> { | ||||
|     alt(( | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander