(self, s: str, loc: int, toks: ParseResults)
| 2580 | return False |
| 2581 | |
| 2582 | def subsuper(self, s: str, loc: int, toks: ParseResults) -> T.Any: |
| 2583 | nucleus = toks.get("nucleus", Hbox(0)) |
| 2584 | subsuper = toks.get("subsuper", []) |
| 2585 | napostrophes = len(toks.get("apostrophes", [])) |
| 2586 | |
| 2587 | if not subsuper and not napostrophes: |
| 2588 | return nucleus |
| 2589 | |
| 2590 | sub = super = None |
| 2591 | while subsuper: |
| 2592 | op, arg, *subsuper = subsuper |
| 2593 | if op == '_': |
| 2594 | if sub is not None: |
| 2595 | raise ParseFatalException("Double subscript") |
| 2596 | sub = arg |
| 2597 | else: |
| 2598 | if super is not None: |
| 2599 | raise ParseFatalException("Double superscript") |
| 2600 | super = arg |
| 2601 | |
| 2602 | state = self.get_state() |
| 2603 | rule_thickness = state.fontset.get_underline_thickness( |
| 2604 | state.font, state.fontsize, state.dpi) |
| 2605 | x_height = state.fontset.get_xheight(state.font, state.fontsize, state.dpi) |
| 2606 | |
| 2607 | if napostrophes: |
| 2608 | if super is None: |
| 2609 | super = Hlist([]) |
| 2610 | for i in range(napostrophes): |
| 2611 | super.children.extend(self.symbol(s, loc, {"sym": "\\prime"})) |
| 2612 | # kern() and hpack() needed to get the metrics right after |
| 2613 | # extending |
| 2614 | super.kern() |
| 2615 | super.hpack() |
| 2616 | |
| 2617 | # Handle over/under symbols, such as sum or prod |
| 2618 | if self.is_overunder(nucleus): |
| 2619 | vlist = [] |
| 2620 | shift = 0. |
| 2621 | width = nucleus.width |
| 2622 | if super is not None: |
| 2623 | super.shrink() |
| 2624 | width = max(width, super.width) |
| 2625 | if sub is not None: |
| 2626 | sub.shrink() |
| 2627 | width = max(width, sub.width) |
| 2628 | |
| 2629 | vgap = rule_thickness * 3.0 |
| 2630 | if super is not None: |
| 2631 | hlist = HCentered([super]) |
| 2632 | hlist.hpack(width, 'exactly') |
| 2633 | vlist.extend([hlist, Vbox(0, vgap)]) |
| 2634 | hlist = HCentered([nucleus]) |
| 2635 | hlist.hpack(width, 'exactly') |
| 2636 | vlist.append(hlist) |
| 2637 | if sub is not None: |
| 2638 | hlist = HCentered([sub]) |
| 2639 | hlist.hpack(width, 'exactly') |
nothing calls this directly
no test coverage detected