natter/src/intermediate/latex_fragment.rs
Tom Alexander 397d4ea0bc
All checks were successful
rust-test Build rust-test has succeeded
rust-clippy Build rust-clippy has succeeded
build-natter Build build-natter has succeeded
format Build format has succeeded
Fix clippy issues.
2023-12-23 07:08:06 -05:00

30 lines
912 B
Rust

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(),
})
}
);