Skip to content

Commit f9cea50

Browse files
committed
Support \sqrt[not-a-number]{...}.
1 parent 15f6905 commit f9cea50

File tree

3 files changed

+68
-3
lines changed

3 files changed

+68
-3
lines changed

lib/matplotlib/_mathtext.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2158,7 +2158,8 @@ def __init__(self):
21582158

21592159
p.sqrt <<= Group(
21602160
Suppress(Literal(r"\sqrt"))
2161-
- ((Optional(p.lbracket + p.int_literal + p.rbracket, default=None)
2161+
- ((Group(Optional(
2162+
p.lbracket + OneOrMore(~p.rbracket + p.token) + p.rbracket))
21622163
+ p.required_group)
21632164
| Error("Expected \\sqrt{value}"))
21642165
)
@@ -2864,10 +2865,10 @@ def sqrt(self, s, loc, toks):
28642865

28652866
# Add the root and shift it upward so it is above the tick.
28662867
# The value of 0.6 is a hard-coded hack ;)
2867-
if root is None:
2868+
if not root:
28682869
root = Box(check.width * 0.5, 0., 0.)
28692870
else:
2870-
root = Hlist([Char(x, state) for x in root])
2871+
root = Hlist(root)
28712872
root.shrink()
28722873
root.shrink()
28732874

lib/matplotlib/tests/test_mathtext.py

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
r'$\dfrac{\$100.00}{y}$', # github issue #1888
114114
]
115115
svg_only_math_tests = [
116+
r'$\sqrt[ab]{123}$', # github issue #8665
116117
]
117118

118119
digits = "0123456789"

0 commit comments

Comments
 (0)