Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7f65d6b

Browse filesBrowse files
devRDksunden
andcommitted
Add unclosed group to grammar
Co-authored-by: Kyle Sunden <git@ksunden.space>
1 parent 69d796a commit 7f65d6b
Copy full SHA for 7f65d6b

File tree

2 files changed

+7
-2
lines changed
Filter options

2 files changed

+7
-2
lines changed

‎lib/matplotlib/_mathtext.py

Copy file name to clipboardExpand all lines: lib/matplotlib/_mathtext.py
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,6 +1894,7 @@ def csnames(group, names):
18941894
p.function = csnames("name", self._function_names)
18951895

18961896
p.group = p.start_group + ZeroOrMore(p.token)("group") + p.end_group
1897+
p.unclosed_group = (p.start_group + ZeroOrMore(p.token)("group") + StringEnd())
18971898

18981899
p.frac = cmd(r"\frac", p.required_group("num") + p.required_group("den"))
18991900
p.dfrac = cmd(r"\dfrac", p.required_group("num") + p.required_group("den"))
@@ -1942,6 +1943,7 @@ def csnames(group, names):
19421943
p.token <<= (
19431944
p.simple
19441945
| p.auto_delim
1946+
| p.unclosed_group
19451947
| p.unknown_symbol # Must be last
19461948
)
19471949

@@ -2251,6 +2253,9 @@ def end_group(self, s, loc, toks):
22512253
self.pop_state()
22522254
return []
22532255

2256+
def unclosed_group(self, s, loc, toks):
2257+
raise ParseFatalException(s, len(s), "Expected '}'")
2258+
22542259
def font(self, s, loc, toks):
22552260
self.get_state().font = toks["font"]
22562261
return []

‎lib/matplotlib/tests/test_mathtext.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_mathtext.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def test_fontinfo():
320320
(r'$a^2^2$', r'Double superscript'),
321321
(r'$a_2_2$', r'Double subscript'),
322322
(r'$a^2_a^2$', r'Double superscript'),
323-
(r'$a = {b$', r'Expected end of text'),
323+
(r'$a = {b$', r"Expected '}'"),
324324
],
325325
ids=[
326326
'hspace without value',
@@ -349,7 +349,7 @@ def test_fontinfo():
349349
'double superscript',
350350
'double subscript',
351351
'super on sub without braces',
352-
'math string with no closing braces'
352+
'unclosed group'
353353
]
354354
)
355355
def test_mathtext_exceptions(math, msg):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.