mathml_latex/parser/
sup_sub.rs

1use super::*;
2
3impl<'i> LaTeXNode<'i> {
4    pub fn is_super_script(&self) -> bool {
5        matches!(self, LaTeXNode::Superscript { .. })
6    }
7
8    pub(super) fn parse_super_script(input: ParseState<'i>) -> ParseResult<LaTeXNode<'i>> {
9        let (state, lhs) = input.match_fn(Self::parse_atomic)?;
10        if lhs.is_super_script() {
11            // StopBecause::ShouldNotBe("^", state.start_offset)
12            todo!()
13        }
14        let (state, _) = state.skip(whitespace).match_str("^", false)?;
15        let (state, rhs) = state.skip(whitespace).match_fn(Self::parse_atomic)?;
16        state.finish(LaTeXNode::Superscript { lhs: Box::new(lhs), rhs: Box::new(rhs) })
17    }
18}