Parse expression *s* using the given *fonts_object* for output, at the given *fontsize* and *dpi*. Returns the parse tree of `Node` instances.
(self, s: str, fonts_object: Fonts, fontsize: float, dpi: float)
| 2291 | self._needs_space_after_subsuper = False |
| 2292 | |
| 2293 | def parse(self, s: str, fonts_object: Fonts, fontsize: float, dpi: float) -> Hlist: |
| 2294 | """ |
| 2295 | Parse expression *s* using the given *fonts_object* for |
| 2296 | output, at the given *fontsize* and *dpi*. |
| 2297 | |
| 2298 | Returns the parse tree of `Node` instances. |
| 2299 | """ |
| 2300 | self._state_stack = [ |
| 2301 | ParserState(fonts_object, 'default', 'rm', fontsize, dpi)] |
| 2302 | self._em_width_cache: dict[tuple[str, float, float], float] = {} |
| 2303 | try: |
| 2304 | result = self._expression.parse_string(s) |
| 2305 | except ParseBaseException as err: |
| 2306 | raise ValueError("\n" + err.explain(0)) from None |
| 2307 | self._state_stack = [] |
| 2308 | self._needs_space_after_subsuper = False |
| 2309 | # prevent operator spacing from leaking into a new expression |
| 2310 | self._em_width_cache = {} |
| 2311 | ParserElement.reset_cache() |
| 2312 | return T.cast(Hlist, result[0]) # Known return type from main. |
| 2313 | |
| 2314 | def get_state(self) -> ParserState: |
| 2315 | """Get the current `State` of the parser.""" |