Rename the parser for bold and link.
This commit is contained in:
		
							parent
							
								
									58f2f4e6aa
								
							
						
					
					
						commit
						7fc19cc9a6
					
				| @ -10,9 +10,9 @@ use super::text::symbol; | ||||
| use super::text::Bold; | ||||
| use super::text::Res; | ||||
| use super::text::TextElement; | ||||
| use super::text_element_parser::_in_section; | ||||
| use super::text_element_parser::_preceded_by_whitespace; | ||||
| use super::text_element_parser::flat_text_element; | ||||
| use super::text_element_parser::in_section; | ||||
| use super::Context; | ||||
| use nom::branch::alt; | ||||
| use nom::bytes::complete::tag; | ||||
| @ -21,7 +21,7 @@ use nom::combinator::peek; | ||||
| use nom::combinator::recognize; | ||||
| use nom::sequence::tuple; | ||||
| 
 | ||||
| pub fn flat_bold<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<'s>> { | ||||
| pub fn bold<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Bold<'s>> { | ||||
|     let bold_start = parser_with_context!(context_bold_start)(&context); | ||||
|     let parser_context = context | ||||
|         .with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode { | ||||
| @ -36,7 +36,7 @@ pub fn flat_bold<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, B | ||||
| } | ||||
| 
 | ||||
| fn can_start_bold<'s, 'r>(context: Context<'r, 's>) -> bool { | ||||
|     _preceded_by_whitespace(context) && !_in_section(context, "bold") | ||||
|     _preceded_by_whitespace(context) && !in_section(context, "bold") | ||||
| } | ||||
| 
 | ||||
| fn context_bold_start<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> { | ||||
|  | ||||
| @ -10,14 +10,14 @@ use super::text::symbol; | ||||
| use super::text::Link; | ||||
| use super::text::Res; | ||||
| use super::text::TextElement; | ||||
| use super::text_element_parser::_in_section; | ||||
| use super::text_element_parser::flat_text_element; | ||||
| use super::text_element_parser::in_section; | ||||
| use super::Context; | ||||
| use nom::combinator::map; | ||||
| use nom::combinator::recognize; | ||||
| use nom::sequence::tuple; | ||||
| 
 | ||||
| pub fn flat_link<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Link<'s>> { | ||||
| pub fn link<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, Link<'s>> { | ||||
|     let link_start = parser_with_context!(context_link_start)(&context); | ||||
|     let parser_context = context | ||||
|         .with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode { | ||||
| @ -32,7 +32,7 @@ pub fn flat_link<'s, 'r>(context: Context<'r, 's>, i: &'s str) -> Res<&'s str, L | ||||
| } | ||||
| 
 | ||||
| fn can_start_link<'s, 'r>(context: Context<'r, 's>) -> bool { | ||||
|     !_in_section(context, "link") | ||||
|     !in_section(context, "link") | ||||
| } | ||||
| 
 | ||||
| fn context_link_start<'s, 'r>(context: Context<'r, 's>, input: &'s str) -> Res<&'s str, &'s str> { | ||||
|  | ||||
| @ -2,10 +2,10 @@ | ||||
| use crate::parser::parser_with_context::parser_with_context; | ||||
| use crate::parser::text::paragraph_end; | ||||
| 
 | ||||
| use super::bold::flat_bold; | ||||
| use super::bold::bold; | ||||
| use super::combinator::context_many1; | ||||
| use super::combinator::context_many_till; | ||||
| use super::link::flat_link; | ||||
| use super::link::link; | ||||
| use super::parser_context::ChainBehavior; | ||||
| use super::parser_context::ContextElement; | ||||
| use super::parser_context::ContextTree; | ||||
| @ -47,7 +47,7 @@ pub fn context_paragraph_end<'s, 'r>( | ||||
|     paragraph_end(input) | ||||
| } | ||||
| 
 | ||||
| pub fn _in_section<'s, 'r, 'x>(context: Context<'r, 's>, section_name: &'x str) -> bool { | ||||
| pub fn in_section<'s, 'r, 'x>(context: Context<'r, 's>, section_name: &'x str) -> bool { | ||||
|     for thing in context.iter() { | ||||
|         match thing.get_data() { | ||||
|             ContextElement::ExitMatcherNode(_) => {} | ||||
| @ -125,8 +125,8 @@ pub fn flat_text_element<'s, 'r>( | ||||
| ) -> Res<&'s str, TextElement<'s>> { | ||||
|     not(|i| context.check_exit_matcher(i))(i)?; | ||||
| 
 | ||||
|     let bold_matcher = parser_with_context!(flat_bold)(&context); | ||||
|     let link_matcher = parser_with_context!(flat_link)(&context); | ||||
|     let bold_matcher = parser_with_context!(bold)(&context); | ||||
|     let link_matcher = parser_with_context!(link)(&context); | ||||
| 
 | ||||
|     alt(( | ||||
|         map(bold_matcher, TextElement::Bold), | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander