2023-10-31 19:14:36 -04:00
|
|
|
use super::macros::intermediate;
|
2023-10-29 22:31:29 -04:00
|
|
|
|
2023-10-29 17:29:16 -04:00
|
|
|
use crate::error::CustomError;
|
2023-10-27 17:48:19 -04:00
|
|
|
|
2023-10-31 19:14:36 -04:00
|
|
|
#[derive(Debug, Clone)]
|
|
|
|
pub(crate) struct ILatexFragment {
|
|
|
|
pub(crate) value: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
intermediate!(ILatexFragment, LatexFragment, original, _registry, {
|
|
|
|
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 })
|
|
|
|
});
|