Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9b177a9

Browse files
authored
Merge pull request #7736 from rtrhd/fixissue7615
Fix mathtext parsing of combined super/sub-scripts issue #7615
2 parents 8d41551 + 7ff4bca commit 9b177a9

17 files changed

+784
-11
lines changed

lib/matplotlib/mathtext.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2881,21 +2881,18 @@ def subsuper(self, s, loc, toks):
28812881
return toks[0] # .asList()
28822882
else:
28832883
nucleus = toks[0]
2884-
elif len(toks) == 2:
2885-
op, next = toks
2886-
nucleus = Hbox(0.0)
2887-
if op == '_':
2888-
sub = next
2889-
else:
2890-
super = next
2891-
elif len(toks) == 3:
2892-
nucleus, op, next = toks
2884+
elif len(toks) in (2, 3):
2885+
# single subscript or superscript
2886+
nucleus = toks[0] if len(toks) == 3 else Hbox(0.0)
2887+
op, next = toks[-2:]
28932888
if op == '_':
28942889
sub = next
28952890
else:
28962891
super = next
2897-
elif len(toks) == 5:
2898-
nucleus, op1, next1, op2, next2 = toks
2892+
elif len(toks) in (4, 5):
2893+
# subscript and superscript
2894+
nucleus = toks[0] if len(toks) == 5 else Hbox(0.0)
2895+
op1, next1, op2, next2 = toks[-4:]
28992896
if op1 == op2:
29002897
if op1 == '_':
29012898
raise ParseFatalException("Double subscript")
Binary file not shown.
Lines changed: 222 additions & 0 deletions
Loading
Binary file not shown.
Lines changed: 136 additions & 0 deletions
Loading
Binary file not shown.

0 commit comments

Comments
 (0)