#![recursion_limit = "1024"]
#[macro_use]
extern crate error_chain;
pub mod errors {
error_chain! {
}
}
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate log;
#[macro_use]
extern crate cfg_if;
pub mod interface;
#[cfg(feature = "include-zip")]
pub use shim_filesystem::ZIPPED_RULE_FILES;
mod canonicalize;
mod infer_intent;
pub mod speech;
mod braille;
mod navigate;
mod prefs;
mod tts;
mod xpath_functions;
mod definitions;
mod pretty_print;
mod chemistry;
pub mod shim_filesystem; pub use interface::*;
#[cfg(test)]
pub fn init_logger() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug"))
.is_test(true)
.format_timestamp(None)
.format_module_path(false)
.format_indent(None)
.format_level(false)
.init();
}
#[cfg(test)]
pub fn abs_rules_dir_path() -> String {
return std::env::current_exe().unwrap().parent().unwrap()
.join("../../../Rules")
.to_str().unwrap().to_string();
}
#[cfg(test)]
pub fn are_strs_canonically_equal_with_locale(test: &str, target: &str, block_separators: &str, decimal_separators: &str) -> bool {
use crate::{interface::*, pretty_print::mml_to_string};
use sxd_document::parser;
use crate::canonicalize::canonicalize;
crate::interface::set_rules_dir(abs_rules_dir_path()).unwrap();
crate::speech::SPEECH_RULES.with(|rules| rules.borrow_mut().read_files().unwrap());
set_preference("BlockSeparators".to_string(), block_separators.to_string()).unwrap();
set_preference("DecimalSeparators".to_string(), decimal_separators.to_string()).unwrap();
let package1 = &parser::parse(test).expect("Failed to parse test input");
let mathml = get_element(package1);
trim_element(&mathml);
let mathml_test = canonicalize(mathml).unwrap();
let package2 = &parser::parse(target).expect("Failed to parse target input");
let mathml_target = get_element(package2);
trim_element(&mathml_target);
match is_same_element(&mathml_test, &mathml_target) {
Ok(_) => return true,
Err(e) => panic!("{}\nResult:\n{}\nTarget:\n{}", e, mml_to_string(&mathml_test), mml_to_string(&mathml_target)),
}
}
#[cfg(test)]
pub fn are_strs_canonically_equal(test: &str, target: &str) -> bool {
return are_strs_canonically_equal_with_locale(test, target, ", \u{00A0}\u{202F}", ".");
}