Skip to content

Commit 4a0b099

Browse files
committed
Add middle for auto delims
1 parent fdd1d1b commit 4a0b099

21 files changed

+2454
-2281
lines changed

lib/matplotlib/_mathtext.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1965,9 +1965,10 @@ def csnames(group, names):
19651965
| p.boldsymbol
19661966
)
19671967

1968+
mdelim = r"\middle" - (p.delim("mdelim") | Error("Expected a delimiter"))
19681969
p.auto_delim <<= (
19691970
r"\left" - (p.delim("left") | Error("Expected a delimiter"))
1970-
+ ZeroOrMore(p.simple | p.auto_delim)("mid")
1971+
+ ZeroOrMore(p.simple | p.auto_delim | mdelim)("mid")
19711972
+ r"\right" - (p.delim("right") | Error("Expected a delimiter"))
19721973
)
19731974

@@ -2586,13 +2587,24 @@ def overline(self, s, loc, toks):
25862587
def _auto_sized_delimiter(self, front, middle, back):
25872588
state = self.get_state()
25882589
if len(middle):
2589-
height = max(x.height for x in middle)
2590-
depth = max(x.depth for x in middle)
2590+
height = max([x.height for x in middle if not isinstance(x, str)])
2591+
depth = max([x.depth for x in middle if not isinstance(x, str)])
25912592
factor = None
25922593
else:
25932594
height = 0
25942595
depth = 0
25952596
factor = 1.0
2597+
2598+
for idx, el in enumerate(middle):
2599+
if isinstance(el, str) and el == '\\middle':
2600+
c = middle[idx + 1]
2601+
if c != '.':
2602+
middle[idx + 1] = AutoHeightChar(
2603+
c, height, depth, state, factor=factor)
2604+
else:
2605+
middle.remove(c)
2606+
del middle[idx]
2607+
25962608
parts = []
25972609
# \left. and \right. aren't supposed to produce any symbols
25982610
if front != '.':
Binary file not shown.

0 commit comments

Comments
 (0)