Copy the value of latex fragments through the pipeline.

This commit is contained in:
Tom Alexander
2023-10-31 19:14:36 -04:00
parent e2f9938437
commit 8695cf17c5
5 changed files with 81 additions and 23 deletions

View File

@@ -1,5 +1,19 @@
use super::macros::inoop;
use super::macros::intermediate;
use crate::error::CustomError;
inoop!(ILatexFragment, LatexFragment);
#[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 })
});