Fix post blank for comment.
This commit is contained in:
		
							parent
							
								
									4af0d3141f
								
							
						
					
					
						commit
						670209e9fc
					
				| @ -46,7 +46,7 @@ pub(crate) fn comment<'b, 'g, 'r, 's>( | ||||
|     let (remaining, mut remaining_lines) = | ||||
|         many0(preceded(not(exit_matcher), comment_line_matcher))(remaining)?; | ||||
| 
 | ||||
|     let (remaining, _trailing_ws) = | ||||
|     let (remaining, post_blank) = | ||||
|         maybe_consume_trailing_whitespace_if_not_exiting(context, remaining)?; | ||||
|     let source = get_consumed(input, remaining); | ||||
|     let mut value = Vec::with_capacity(remaining_lines.len() + 1); | ||||
| @ -67,6 +67,7 @@ pub(crate) fn comment<'b, 'g, 'r, 's>( | ||||
|         Comment { | ||||
|             source: source.into(), | ||||
|             value, | ||||
|             post_blank: post_blank.map(Into::<&str>::into), | ||||
|         }, | ||||
|     )) | ||||
| } | ||||
|  | ||||
| @ -35,6 +35,7 @@ pub struct Paragraph<'s> { | ||||
| pub struct Comment<'s> { | ||||
|     pub source: &'s str, | ||||
|     pub value: Vec<&'s str>, | ||||
|     pub post_blank: Option<&'s str>, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| @ -242,7 +243,11 @@ impl<'s> StandardProperties<'s> for Comment<'s> { | ||||
|     } | ||||
| 
 | ||||
|     fn get_post_blank(&self) -> PostBlank { | ||||
|         0 | ||||
|         self.post_blank | ||||
|             .map(|text| text.lines().count()) | ||||
|             .unwrap_or(0) | ||||
|             .try_into() | ||||
|             .expect("Too much post-blank to fit into a PostBlank.") | ||||
|     } | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander