use super::macros::intermediate; use crate::error::CustomError; use organic::types::StandardProperties; #[derive(Debug, Clone)] pub(crate) struct ILatexFragment { pub(crate) value: String, pub(crate) post_blank: organic::types::PostBlank, } intermediate!( ILatexFragment, &'orig organic::types::LatexFragment<'parse>, original, _intermediate_context, { let value: String = if original.value.starts_with("$$") && original.value.ends_with("$$") { format!("\\[{}\\]", &original.value[2..(original.value.len() - 2)]) } else if original.value.starts_with('$') && original.value.ends_with('$') { format!("\\({}\\)", &original.value[1..(original.value.len() - 1)]) } else { original.value.to_owned() }; Ok(ILatexFragment { value, post_blank: original.get_post_blank(), }) } );