blob: 09f52164f7c7e4599b9476141c5cf1be9507f526 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
use std::fmt::Write;
use super::*;
use crate::library::prelude::*;
/// A sub- and/or superscript in a mathematical formula.
#[derive(Debug, Hash)]
pub struct ScriptNode {
/// The base.
pub base: MathNode,
/// The subscript.
pub sub: Option<MathNode>,
/// The superscript.
pub sup: Option<MathNode>,
}
impl Texify for ScriptNode {
fn texify(&self) -> EcoString {
let mut tex = self.base.texify();
if let Some(sub) = &self.sub {
write!(tex, "_{{{}}}", sub.texify()).unwrap();
}
if let Some(sup) = &self.sup {
write!(tex, "^{{{}}}", sup.texify()).unwrap();
}
tex
}
}
|