Create structure for subscript and superscript.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
use super::util::assert_bounds;
|
||||
use super::util::assert_name;
|
||||
use crate::parser::Subscript;
|
||||
use crate::parser::Superscript;
|
||||
use crate::parser::sexp::Token;
|
||||
use crate::parser::AngleLink;
|
||||
use crate::parser::Bold;
|
||||
@@ -176,6 +178,8 @@ fn compare_object<'s>(
|
||||
Object::LineBreak(obj) => compare_line_break(source, emacs, obj),
|
||||
Object::Target(obj) => compare_target(source, emacs, obj),
|
||||
Object::StatisticsCookie(obj) => compare_statistics_cookie(source, emacs, obj),
|
||||
Object::Subscript(obj) => compare_subscript(source, emacs, obj),
|
||||
Object::Superscript(obj) => compare_superscript(source, emacs, obj),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1513,3 +1517,49 @@ fn compare_statistics_cookie<'s>(
|
||||
children: Vec::new(),
|
||||
})
|
||||
}
|
||||
|
||||
fn compare_subscript<'s>(
|
||||
source: &'s str,
|
||||
emacs: &'s Token<'s>,
|
||||
rust: &'s Subscript<'s>,
|
||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let emacs_name = "subscript";
|
||||
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(),
|
||||
})
|
||||
}
|
||||
|
||||
fn compare_superscript<'s>(
|
||||
source: &'s str,
|
||||
emacs: &'s Token<'s>,
|
||||
rust: &'s Superscript<'s>,
|
||||
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||
let mut this_status = DiffStatus::Good;
|
||||
let emacs_name = "superscript";
|
||||
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(),
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user