Port greater blocker over to ak_element!().
This commit is contained in:
		
							parent
							
								
									5136880532
								
							
						
					
					
						commit
						59448a4f2c
					
				| @ -74,7 +74,14 @@ fn _element<'b, 'g, 'r, 's>( | ||||
|         Element::PlainList | ||||
|     ); | ||||
| 
 | ||||
|     let greater_block_matcher = parser_with_context!(greater_block)(context); | ||||
|     ak_element!( | ||||
|         greater_block, | ||||
|         &mut affiliated_keywords, | ||||
|         post_affiliated_keywords_input, | ||||
|         context, | ||||
|         input | ||||
|     ); | ||||
| 
 | ||||
|     let dynamic_block_matcher = parser_with_context!(dynamic_block)(context); | ||||
|     let footnote_definition_matcher = parser_with_context!(footnote_definition)(context); | ||||
|     let comment_matcher = parser_with_context!(comment)(context); | ||||
| @ -101,7 +108,6 @@ fn _element<'b, 'g, 'r, 's>( | ||||
|         let _enter = span.enter(); | ||||
| 
 | ||||
|         opt(alt(( | ||||
|             greater_block_matcher, | ||||
|             map(dynamic_block_matcher, Element::DynamicBlock), | ||||
|             map(footnote_definition_matcher, Element::FootnoteDefinition), | ||||
|             map(comment_matcher, Element::Comment), | ||||
|  | ||||
| @ -18,7 +18,6 @@ use nom::sequence::preceded; | ||||
| use nom::sequence::tuple; | ||||
| 
 | ||||
| use super::affiliated_keyword::parse_affiliated_keywords; | ||||
| use super::keyword::affiliated_keyword; | ||||
| use super::org_source::OrgSource; | ||||
| use super::util::in_section; | ||||
| use super::util::maybe_consume_trailing_whitespace_if_not_exiting; | ||||
| @ -48,12 +47,15 @@ use crate::types::SpecialBlock; | ||||
|     feature = "tracing", | ||||
|     tracing::instrument(ret, level = "debug", skip(context)) | ||||
| )] | ||||
| pub(crate) fn greater_block<'b, 'g, 'r, 's>( | ||||
|     context: RefContext<'b, 'g, 'r, 's>, | ||||
| pub(crate) fn greater_block<'b, 'g, 'r, 's, AK>( | ||||
|     affiliated_keywords: AK, | ||||
|     input: OrgSource<'s>, | ||||
| ) -> Res<OrgSource<'s>, Element<'s>> { | ||||
|     let pre_affiliated_keywords_input = input; | ||||
|     let (input, affiliated_keywords) = many0(affiliated_keyword)(input)?; | ||||
|     context: RefContext<'b, 'g, 'r, 's>, | ||||
|     pre_affiliated_keywords_input: OrgSource<'s>, | ||||
| ) -> Res<OrgSource<'s>, Element<'s>> | ||||
| where | ||||
|     AK: IntoIterator<Item = Keyword<'s>>, | ||||
| { | ||||
|     start_of_line(input)?; | ||||
|     let (remaining, _leading_whitespace) = space0(input)?; | ||||
|     let (remaining, (_begin, name)) = tuple(( | ||||
| @ -93,12 +95,15 @@ pub(crate) fn greater_block<'b, 'g, 'r, 's>( | ||||
|     feature = "tracing", | ||||
|     tracing::instrument(ret, level = "debug", skip(context)) | ||||
| )] | ||||
| fn center_block<'b, 'g, 'r, 's>( | ||||
| fn center_block<'b, 'g, 'r, 's, AK>( | ||||
|     context: RefContext<'b, 'g, 'r, 's>, | ||||
|     input: OrgSource<'s>, | ||||
|     pre_affiliated_keywords_input: OrgSource<'s>, | ||||
|     affiliated_keywords: Vec<Keyword<'s>>, | ||||
| ) -> Res<OrgSource<'s>, Element<'s>> { | ||||
|     affiliated_keywords: AK, | ||||
| ) -> Res<OrgSource<'s>, Element<'s>> | ||||
| where | ||||
|     AK: IntoIterator<Item = Keyword<'s>>, | ||||
| { | ||||
|     let (remaining, (source, children)) = greater_block_body( | ||||
|         context, | ||||
|         input, | ||||
| @ -123,12 +128,15 @@ fn center_block<'b, 'g, 'r, 's>( | ||||
|     feature = "tracing", | ||||
|     tracing::instrument(ret, level = "debug", skip(context)) | ||||
| )] | ||||
| fn quote_block<'b, 'g, 'r, 's>( | ||||
| fn quote_block<'b, 'g, 'r, 's, AK>( | ||||
|     context: RefContext<'b, 'g, 'r, 's>, | ||||
|     input: OrgSource<'s>, | ||||
|     pre_affiliated_keywords_input: OrgSource<'s>, | ||||
|     affiliated_keywords: Vec<Keyword<'s>>, | ||||
| ) -> Res<OrgSource<'s>, Element<'s>> { | ||||
|     affiliated_keywords: AK, | ||||
| ) -> Res<OrgSource<'s>, Element<'s>> | ||||
| where | ||||
|     AK: IntoIterator<Item = Keyword<'s>>, | ||||
| { | ||||
|     let (remaining, (source, children)) = greater_block_body( | ||||
|         context, | ||||
|         input, | ||||
| @ -149,15 +157,18 @@ fn quote_block<'b, 'g, 'r, 's>( | ||||
|     )) | ||||
| } | ||||
| 
 | ||||
| fn special_block<'s>( | ||||
| fn special_block<'s, AK>( | ||||
|     name: &'s str, | ||||
| ) -> impl for<'b, 'g, 'r> Fn( | ||||
|     RefContext<'b, 'g, 'r, 's>, | ||||
|     OrgSource<'s>, | ||||
|     OrgSource<'s>, | ||||
|     Vec<Keyword<'s>>, | ||||
|     AK, | ||||
| ) -> Res<OrgSource<'s>, Element<'s>> | ||||
|        + 's { | ||||
|        + 's | ||||
| where | ||||
|     AK: IntoIterator<Item = Keyword<'s>>, | ||||
| { | ||||
|     let context_name = format!("special block {}", name); | ||||
|     move |context, input, pre_affiliated_keywords_input, affiliated_keywords| { | ||||
|         _special_block( | ||||
| @ -175,14 +186,17 @@ fn special_block<'s>( | ||||
|     feature = "tracing", | ||||
|     tracing::instrument(ret, level = "debug", skip(context)) | ||||
| )] | ||||
| fn _special_block<'c, 'b, 'g, 'r, 's>( | ||||
| fn _special_block<'c, 'b, 'g, 'r, 's, AK>( | ||||
|     context: RefContext<'b, 'g, 'r, 's>, | ||||
|     input: OrgSource<'s>, | ||||
|     pre_affiliated_keywords_input: OrgSource<'s>, | ||||
|     name: &'s str, | ||||
|     context_name: &'c str, | ||||
|     affiliated_keywords: Vec<Keyword<'s>>, | ||||
| ) -> Res<OrgSource<'s>, Element<'s>> { | ||||
|     affiliated_keywords: AK, | ||||
| ) -> Res<OrgSource<'s>, Element<'s>> | ||||
| where | ||||
|     AK: IntoIterator<Item = Keyword<'s>>, | ||||
| { | ||||
|     let (remaining, parameters) = opt(tuple((space1, parameters)))(input)?; | ||||
|     let (remaining, (source, children)) = greater_block_body( | ||||
|         context, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander