There was an error while loading. Please reload this page.
2 parents d8e989d + b5d9b43 commit def68deCopy full SHA for def68de
3 files changed
lib/matplotlib/_mathtext.py
@@ -1965,9 +1965,10 @@ def csnames(group, names):
1965
| p.boldsymbol
1966
)
1967
1968
+ mdelim = r"\middle" - (p.delim("mdelim") | Error("Expected a delimiter"))
1969
p.auto_delim <<= (
1970
r"\left" - (p.delim("left") | Error("Expected a delimiter"))
- + ZeroOrMore(p.simple | p.auto_delim)("mid")
1971
+ + ZeroOrMore(p.simple | p.auto_delim | mdelim)("mid")
1972
+ r"\right" - (p.delim("right") | Error("Expected a delimiter"))
1973
1974
@@ -2586,13 +2587,23 @@ def overline(self, s, loc, toks):
2586
2587
def _auto_sized_delimiter(self, front, middle, back):
2588
state = self.get_state()
2589
if len(middle):
- height = max(x.height for x in middle)
2590
- depth = max(x.depth for x in middle)
+ 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)])
2592
factor = None
2593
+ for idx, el in enumerate(middle):
2594
+ if isinstance(el, str) and el == '\\middle':
2595
+ c = middle[idx + 1]
2596
+ if c != '.':
2597
+ middle[idx + 1] = AutoHeightChar(
2598
+ c, height, depth, state, factor=factor)
2599
+ else:
2600
+ middle.remove(c)
2601
+ del middle[idx]
2602
else:
2603
height = 0
2604
depth = 0
2605
factor = 1.0
2606
+
2607
parts = []
2608
# \left. and \right. aren't supposed to produce any symbols
2609
if front != '.':
lib/matplotlib/tests/baseline_images/test_mathtext/mathtext1_dejavusans_07.png
5.56 KB
lib/matplotlib/tests/test_mathtext.py
@@ -136,6 +136,7 @@
136
r'$\text{text}_{\text{sub}}^{\text{sup}} + \text{\$foo\$} + \frac{\text{num}}{\mathbf{\text{den}}}\text{with space, curly brackets \{\}, and dash -}$',
137
r'$\boldsymbol{abcde} \boldsymbol{+} \boldsymbol{\Gamma + \Omega} \boldsymbol{01234} \boldsymbol{\alpha * \beta}$',
138
r'$\left\lbrace\frac{\left\lbrack A^b_c\right\rbrace}{\left\leftbrace D^e_f \right\rbrack}\right\rightbrace\ \left\leftparen\max_{x} \left\lgroup \frac{A}{B}\right\rgroup \right\rightparen$',
139
+ r'$\left( a\middle. b \right)$ $\left( \frac{a}{b} \middle\vert x_i \in P^S \right)$ $\left[ 1 - \middle| a\middle| + \left( x - \left\lfloor \dfrac{a}{b}\right\rfloor \right) \right]$',
140
]
141
142
digits = "0123456789"
0 commit comments