Create structure for line breaks.
This commit is contained in:
		
							parent
							
								
									6b82214ec3
								
							
						
					
					
						commit
						4d114206ef
					
				| @ -31,6 +31,7 @@ use crate::parser::Italic; | ||||
| use crate::parser::Keyword; | ||||
| use crate::parser::LatexEnvironment; | ||||
| use crate::parser::LatexFragment; | ||||
| use crate::parser::LineBreak; | ||||
| use crate::parser::Object; | ||||
| use crate::parser::OrgMacro; | ||||
| use crate::parser::Paragraph; | ||||
| @ -170,6 +171,7 @@ fn compare_object<'s>( | ||||
|         Object::CitationReference(obj) => compare_citation_reference(source, emacs, obj), | ||||
|         Object::InlineBabelCall(obj) => compare_inline_babel_call(source, emacs, obj), | ||||
|         Object::InlineSourceBlock(obj) => compare_inline_source_block(source, emacs, obj), | ||||
|         Object::LineBreak(obj) => compare_line_break(source, emacs, obj), | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| @ -1438,3 +1440,26 @@ fn compare_inline_source_block<'s>( | ||||
|         children: Vec::new(), | ||||
|     }) | ||||
| } | ||||
| 
 | ||||
| fn compare_line_break<'s>( | ||||
|     source: &'s str, | ||||
|     emacs: &'s Token<'s>, | ||||
|     rust: &'s LineBreak<'s>, | ||||
| ) -> Result<DiffResult, Box<dyn std::error::Error>> { | ||||
|     let mut this_status = DiffStatus::Good; | ||||
|     let emacs_name = "line-break"; | ||||
|     if assert_name(emacs, emacs_name).is_err() { | ||||
|         this_status = DiffStatus::Bad; | ||||
|     } | ||||
| 
 | ||||
|     if assert_bounds(source, emacs, rust).is_err() { | ||||
|         this_status = DiffStatus::Bad; | ||||
|     } | ||||
| 
 | ||||
|     Ok(DiffResult { | ||||
|         status: this_status, | ||||
|         name: emacs_name.to_owned(), | ||||
|         message: None, | ||||
|         children: Vec::new(), | ||||
|     }) | ||||
| } | ||||
|  | ||||
							
								
								
									
										13
									
								
								src/parser/line_break.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/parser/line_break.rs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,13 @@ | ||||
| use super::Context; | ||||
| use crate::error::Res; | ||||
| use crate::parser::util::not_yet_implemented; | ||||
| use crate::parser::CitationReference; | ||||
| 
 | ||||
| #[tracing::instrument(ret, level = "debug")] | ||||
| pub fn citation_reference<'r, 's>( | ||||
|     context: Context<'r, 's>, | ||||
|     input: &'s str, | ||||
| ) -> Res<&'s str, CitationReference<'s>> { | ||||
|     not_yet_implemented()?; | ||||
|     todo!() | ||||
| } | ||||
| @ -25,6 +25,7 @@ mod latex_environment; | ||||
| mod latex_fragment; | ||||
| mod lesser_block; | ||||
| mod lesser_element; | ||||
| mod line_break; | ||||
| mod list; | ||||
| mod object; | ||||
| mod object_parser; | ||||
| @ -87,6 +88,7 @@ pub use object::InlineBabelCall; | ||||
| pub use object::InlineSourceBlock; | ||||
| pub use object::Italic; | ||||
| pub use object::LatexFragment; | ||||
| pub use object::LineBreak; | ||||
| pub use object::Object; | ||||
| pub use object::OrgMacro; | ||||
| pub use object::PlainLink; | ||||
|  | ||||
| @ -23,6 +23,7 @@ pub enum Object<'s> { | ||||
|     CitationReference(CitationReference<'s>), | ||||
|     InlineBabelCall(InlineBabelCall<'s>), | ||||
|     InlineSourceBlock(InlineSourceBlock<'s>), | ||||
|     LineBreak(LineBreak<'s>), | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug, PartialEq)] | ||||
| @ -149,6 +150,11 @@ pub struct InlineSourceBlock<'s> { | ||||
|     pub source: &'s str, | ||||
| } | ||||
| 
 | ||||
| #[derive(Debug, PartialEq)] | ||||
| pub struct LineBreak<'s> { | ||||
|     pub source: &'s str, | ||||
| } | ||||
| 
 | ||||
| impl<'s> Source<'s> for Object<'s> { | ||||
|     fn get_source(&'s self) -> &'s str { | ||||
|         match self { | ||||
| @ -173,6 +179,7 @@ impl<'s> Source<'s> for Object<'s> { | ||||
|             Object::CitationReference(obj) => obj.source, | ||||
|             Object::InlineBabelCall(obj) => obj.source, | ||||
|             Object::InlineSourceBlock(obj) => obj.source, | ||||
|             Object::LineBreak(obj) => obj.source, | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -296,3 +303,9 @@ impl<'s> Source<'s> for InlineSourceBlock<'s> { | ||||
|         self.source | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl<'s> Source<'s> for LineBreak<'s> { | ||||
|     fn get_source(&'s self) -> &'s str { | ||||
|         self.source | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -62,6 +62,7 @@ impl<'r, 's> Token<'r, 's> { | ||||
|                 Object::CitationReference(_) => Box::new(std::iter::empty()), // TODO: Iterate over children
 | ||||
|                 Object::InlineBabelCall(_) => Box::new(std::iter::empty()), | ||||
|                 Object::InlineSourceBlock(_) => Box::new(std::iter::empty()), | ||||
|                 Object::LineBreak(_) => Box::new(std::iter::empty()), | ||||
|             }, | ||||
|             Token::Element(elem) => match elem { | ||||
|                 Element::Paragraph(inner) => Box::new(inner.children.iter().map(Token::Object)), | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander