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

Skip to content

Commit cd866e9

Browse files
committed
Merge pull request #5880 from zblz/fix-primes
mathtext: Fix bugs in conversion of apostrophes to primes
1 parent 6d4edf0 commit cd866e9

17 files changed

+819
-52
lines changed

lib/matplotlib/mathtext.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2701,12 +2701,15 @@ def subsuper(self, s, loc, toks):
27012701
sub = None
27022702
super = None
27032703

2704-
# Pick all of the apostrophe's out
2704+
# Pick all of the apostrophes out, including first apostrophes that have
2705+
# been parsed as characters
27052706
napostrophes = 0
27062707
new_toks = []
27072708
for tok in toks[0]:
27082709
if isinstance(tok, six.string_types) and tok not in ('^', '_'):
27092710
napostrophes += len(tok)
2711+
elif isinstance(tok, Char) and tok.c == "'":
2712+
napostrophes += 1
27102713
else:
27112714
new_toks.append(tok)
27122715
toks = new_toks
@@ -2761,6 +2764,9 @@ def subsuper(self, s, loc, toks):
27612764
super = Hlist([])
27622765
for i in range(napostrophes):
27632766
super.children.extend(self.symbol(s, loc, ['\prime']))
2767+
# kern() and hpack() needed to get the metrics right after extending
2768+
super.kern()
2769+
super.hpack()
27642770

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

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

Lines changed: 215 additions & 18 deletions
Loading
Binary file not shown.

0 commit comments

Comments
 (0)