Initial structure for tables.

This commit is contained in:
Tom Alexander
2023-04-19 20:59:58 -04:00
parent 1badd3b0fc
commit 17ab8727d1
5 changed files with 54 additions and 0 deletions

View File

@@ -14,6 +14,7 @@ use crate::parser::PlainList;
use crate::parser::PlainListItem;
use crate::parser::PropertyDrawer;
use crate::parser::Section;
use crate::parser::Table;
use crate::DynamicBlock;
#[derive(Debug)]
@@ -198,6 +199,7 @@ fn compare_element<'s>(
Element::Comment(obj) => compare_comment(source, emacs, obj),
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),
}
}
@@ -459,3 +461,28 @@ fn compare_property_drawer<'s>(
children: child_status,
})
}
fn compare_table<'s>(
source: &'s str,
emacs: &'s Token<'s>,
rust: &'s Table<'s>,
) -> Result<DiffResult, Box<dyn std::error::Error>> {
let children = emacs.as_list()?;
let mut child_status = Vec::new();
let mut this_status = DiffStatus::Good;
let emacs_name = "table";
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: child_status,
})
}