2023-10-31 19:14:36 -04:00
|
|
|
use super::macros::intermediate;
|
2023-10-29 17:29:16 -04:00
|
|
|
use crate::error::CustomError;
|
2023-12-21 14:56:58 -05:00
|
|
|
use organic::types::StandardProperties;
|
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,
|
2023-12-21 14:56:58 -05:00
|
|
|
pub(crate) post_blank: organic::types::PostBlank,
|
2023-10-31 19:14:36 -04:00
|
|
|
}
|
|
|
|
|
|
2023-12-19 17:09:11 -05:00
|
|
|
intermediate!(
|
|
|
|
|
ILatexFragment,
|
|
|
|
|
&'orig organic::types::LatexFragment<'parse>,
|
|
|
|
|
original,
|
2023-12-21 13:53:56 -05:00
|
|
|
_intermediate_context,
|
2023-12-19 17:09:11 -05:00
|
|
|
{
|
|
|
|
|
let value: String = if original.value.starts_with("$$") && original.value.ends_with("$$") {
|
|
|
|
|
format!("\\[{}\\]", &original.value[2..(original.value.len() - 2)])
|
2023-12-23 06:38:23 -05:00
|
|
|
} else if original.value.starts_with('$') && original.value.ends_with('$') {
|
2023-12-19 17:09:11 -05:00
|
|
|
format!("\\({}\\)", &original.value[1..(original.value.len() - 1)])
|
|
|
|
|
} else {
|
|
|
|
|
original.value.to_owned()
|
|
|
|
|
};
|
2023-12-21 14:56:58 -05:00
|
|
|
Ok(ILatexFragment {
|
|
|
|
|
value,
|
|
|
|
|
post_blank: original.get_post_blank(),
|
|
|
|
|
})
|
2023-12-19 17:09:11 -05:00
|
|
|
}
|
|
|
|
|
);
|