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

Skip to content

Commit d0186ac

Browse files
committed
Merge pull request #5880 from zblz/fix-primes
mathtext: Fix bugs in conversion of apostrophes to primes
2 parents c259a55 + 736138b commit d0186ac

17 files changed

+694
-61
lines changed

lib/matplotlib/mathtext.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2852,12 +2852,15 @@ def subsuper(self, s, loc, toks):
28522852
sub = None
28532853
super = None
28542854

2855-
# Pick all of the apostrophe's out
2855+
# Pick all of the apostrophes out, including first apostrophes that have
2856+
# been parsed as characters
28562857
napostrophes = 0
28572858
new_toks = []
28582859
for tok in toks[0]:
28592860
if isinstance(tok, six.string_types) and tok not in ('^', '_'):
28602861
napostrophes += len(tok)
2862+
elif isinstance(tok, Char) and tok.c == "'":
2863+
napostrophes += 1
28612864
else:
28622865
new_toks.append(tok)
28632866
toks = new_toks
@@ -2912,6 +2915,9 @@ def subsuper(self, s, loc, toks):
29122915
super = Hlist([])
29132916
for i in range(napostrophes):
29142917
super.children.extend(self.symbol(s, loc, ['\prime']))
2918+
# kern() and hpack() needed to get the metrics right after extending
2919+
super.kern()
2920+
super.hpack()
29152921

29162922
# Handle over/under symbols, such as sum or integral
29172923
if self.is_overunder(nucleus):
Binary file not shown.

lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_31.svg

Lines changed: 214 additions & 17 deletions
Loading
Binary file not shown.

0 commit comments

Comments
 (0)