Starting to implement table cell.
This commit is contained in:
		
							parent
							
								
									9747e0ba11
								
							
						
					
					
						commit
						55201e905a
					
				| @ -65,4 +65,10 @@ pub struct Table<'s> { | ||||
| #[derive(Debug)] | ||||
| pub struct TableRow<'s> { | ||||
|     pub source: &'s str, | ||||
|     pub children: Vec<TableCell<'s>>, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug)] | ||||
| pub struct TableCell<'s> { | ||||
|     pub source: &'s str, | ||||
| } | ||||
|  | ||||
| @ -54,3 +54,15 @@ pub fn standard_set_object<'r, 's>( | ||||
| 
 | ||||
|     map(plain_text_matcher, Object::PlainText)(input) | ||||
| } | ||||
| 
 | ||||
| #[tracing::instrument(ret, level = "debug")] | ||||
| pub fn minimal_set_object<'r, 's>( | ||||
|     context: Context<'r, 's>, | ||||
|     input: &'s str, | ||||
| ) -> Res<&'s str, Object<'s>> { | ||||
|     not(|i| context.check_exit_matcher(i))(input)?; | ||||
| 
 | ||||
|     let plain_text_matcher = parser_with_context!(plain_text)(context); | ||||
| 
 | ||||
|     map(plain_text_matcher, Object::PlainText)(input) | ||||
| } | ||||
|  | ||||
| @ -6,13 +6,16 @@ use nom::character::complete::space0; | ||||
| use nom::combinator::not; | ||||
| use nom::combinator::peek; | ||||
| use nom::combinator::recognize; | ||||
| use nom::multi::many1; | ||||
| use nom::multi::many_till; | ||||
| use nom::sequence::tuple; | ||||
| 
 | ||||
| use super::Context; | ||||
| use crate::parser::error::Res; | ||||
| use crate::parser::exiting::ExitClass; | ||||
| use crate::parser::greater_element::TableCell; | ||||
| use crate::parser::greater_element::TableRow; | ||||
| use crate::parser::object::minimal_set_object; | ||||
| use crate::parser::parser_context::ContextElement; | ||||
| use crate::parser::parser_context::ExitMatcherNode; | ||||
| use crate::parser::parser_with_context::parser_with_context; | ||||
| @ -77,7 +80,13 @@ pub fn org_mode_table_row_rule<'r, 's>( | ||||
|     start_of_line(context, input)?; | ||||
|     let (remaining, _) = tuple((space0, tag("|-"), is_not("\r\n"), line_ending))(input)?; | ||||
|     let source = get_consumed(input, remaining); | ||||
|     Ok((remaining, TableRow { source })) | ||||
|     Ok(( | ||||
|         remaining, | ||||
|         TableRow { | ||||
|             source, | ||||
|             children: Vec::new(), | ||||
|         }, | ||||
|     )) | ||||
| } | ||||
| 
 | ||||
| #[tracing::instrument(ret, level = "debug")] | ||||
| @ -85,5 +94,33 @@ pub fn org_mode_table_row_regular<'r, 's>( | ||||
|     context: Context<'r, 's>, | ||||
|     input: &'s str, | ||||
| ) -> Res<&'s str, TableRow<'s>> { | ||||
|     start_of_line(context, input)?; | ||||
|     let (remaining, _) = tuple((space0, tag("|")))(input)?; | ||||
|     let (remaining, children) = | ||||
|         many1(parser_with_context!(org_mode_table_cell)(context))(remaining)?; | ||||
|     let source = get_consumed(input, remaining); | ||||
|     Ok((remaining, TableRow { source, children })) | ||||
| } | ||||
| 
 | ||||
| #[tracing::instrument(ret, level = "debug")] | ||||
| pub fn org_mode_table_cell<'r, 's>( | ||||
|     context: Context<'r, 's>, | ||||
|     input: &'s str, | ||||
| ) -> Res<&'s str, TableCell<'s>> { | ||||
|     let parser_context = | ||||
|         context.with_additional_node(ContextElement::ExitMatcherNode(ExitMatcherNode { | ||||
|             class: ExitClass::Beta, | ||||
|             exit_matcher: &org_mode_table_cell_end, | ||||
|         })); | ||||
|     let minimal_set_object_matcher = parser_with_context!(minimal_set_object)(&parser_context); | ||||
| 
 | ||||
|     todo!() | ||||
| } | ||||
| 
 | ||||
| #[tracing::instrument(ret, level = "debug")] | ||||
| fn org_mode_table_cell_end<'r, 's>( | ||||
|     context: Context<'r, 's>, | ||||
|     input: &'s str, | ||||
| ) -> Res<&'s str, &'s str> { | ||||
|     recognize(tuple((space0, alt((tag("|"), peek(line_ending))))))(input) | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander