Set up code structure for lesser blocks.
This commit is contained in:
parent
142bb09879
commit
0293ca6b12
@ -9,6 +9,7 @@ use crate::parser::Element;
|
||||
use crate::parser::FootnoteDefinition;
|
||||
use crate::parser::GreaterBlock;
|
||||
use crate::parser::Heading;
|
||||
use crate::parser::LesserBlock;
|
||||
use crate::parser::Paragraph;
|
||||
use crate::parser::PlainList;
|
||||
use crate::parser::PlainListItem;
|
||||
@ -202,6 +203,7 @@ fn compare_element<'s>(
|
||||
Element::Drawer(obj) => compare_drawer(source, emacs, obj),
|
||||
Element::PropertyDrawer(obj) => compare_property_drawer(source, emacs, obj),
|
||||
Element::Table(obj) => compare_table(source, emacs, obj),
|
||||
Element::LesserBlock(obj) => compare_lesser_block(source, emacs, obj),
|
||||
}
|
||||
}
|
||||
|
||||
@ -548,3 +550,11 @@ fn compare_table_cell<'s>(
|
||||
children: child_status,
|
||||
})
|
||||
}
|
||||
|
||||
fn compare_lesser_block<'s>(
|
||||
source: &'s str,
|
||||
emacs: &'s Token<'s>,
|
||||
rust: &'s LesserBlock<'s>,
|
||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||
todo!()
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ use super::greater_element::PlainList;
|
||||
use super::greater_element::PropertyDrawer;
|
||||
use super::greater_element::Table;
|
||||
use super::lesser_element::Comment;
|
||||
use super::lesser_element::LesserBlock;
|
||||
use super::lesser_element::Paragraph;
|
||||
use super::source::Source;
|
||||
use super::Drawer;
|
||||
@ -20,6 +21,7 @@ pub enum Element<'s> {
|
||||
Drawer(Drawer<'s>),
|
||||
PropertyDrawer(PropertyDrawer<'s>),
|
||||
Table(Table<'s>),
|
||||
LesserBlock(LesserBlock<'s>),
|
||||
}
|
||||
|
||||
impl<'s> Source<'s> for Element<'s> {
|
||||
@ -34,6 +36,7 @@ impl<'s> Source<'s> for Element<'s> {
|
||||
Element::Drawer(obj) => obj.source,
|
||||
Element::PropertyDrawer(obj) => obj.source,
|
||||
Element::Table(obj) => obj.source,
|
||||
Element::LesserBlock(obj) => obj.source,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ use super::element::Element;
|
||||
use super::error::Res;
|
||||
use super::footnote_definition::footnote_definition;
|
||||
use super::greater_block::greater_block;
|
||||
use super::lesser_block::lesser_block;
|
||||
use super::paragraph::paragraph;
|
||||
use super::plain_list::plain_list;
|
||||
use super::Context;
|
||||
@ -35,6 +36,7 @@ pub fn non_paragraph_element<'r, 's>(
|
||||
let comment_matcher = parser_with_context!(comment)(context);
|
||||
let drawer_matcher = parser_with_context!(drawer)(context);
|
||||
let table_matcher = parser_with_context!(org_mode_table)(context);
|
||||
let lesser_block_matcher = parser_with_context!(lesser_block)(context);
|
||||
alt((
|
||||
map(plain_list_matcher, Element::PlainList),
|
||||
map(greater_block_matcher, Element::GreaterBlock),
|
||||
@ -43,5 +45,6 @@ pub fn non_paragraph_element<'r, 's>(
|
||||
map(comment_matcher, Element::Comment),
|
||||
map(drawer_matcher, Element::Drawer),
|
||||
map(table_matcher, Element::Table),
|
||||
map(lesser_block_matcher, Element::LesserBlock),
|
||||
))(input)
|
||||
}
|
||||
|
11
src/parser/lesser_block.rs
Normal file
11
src/parser/lesser_block.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use super::error::Res;
|
||||
use super::Context;
|
||||
use crate::parser::lesser_element::LesserBlock;
|
||||
|
||||
#[tracing::instrument(ret, level = "debug")]
|
||||
pub fn lesser_block<'r, 's>(
|
||||
context: Context<'r, 's>,
|
||||
input: &'s str,
|
||||
) -> Res<&'s str, LesserBlock<'s>> {
|
||||
todo!()
|
||||
}
|
@ -19,6 +19,14 @@ pub struct TableCell<'s> {
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct LesserBlock<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: &'s str,
|
||||
pub data: Option<&'s str>,
|
||||
pub children: Vec<Object<'s>>,
|
||||
}
|
||||
|
||||
impl<'s> Paragraph<'s> {
|
||||
pub fn of_text(input: &'s str) -> Self {
|
||||
let mut objects = Vec::with_capacity(1);
|
||||
|
@ -9,6 +9,7 @@ mod exiting;
|
||||
mod footnote_definition;
|
||||
mod greater_block;
|
||||
mod greater_element;
|
||||
mod lesser_block;
|
||||
mod lesser_element;
|
||||
mod list;
|
||||
mod object;
|
||||
@ -38,6 +39,7 @@ pub use greater_element::PropertyDrawer;
|
||||
pub use greater_element::Table;
|
||||
pub use greater_element::TableRow;
|
||||
pub use lesser_element::Comment;
|
||||
pub use lesser_element::LesserBlock;
|
||||
pub use lesser_element::Paragraph;
|
||||
pub use lesser_element::TableCell;
|
||||
pub use source::Source;
|
||||
|
Loading…
Reference in New Issue
Block a user