Skip to content

Commit

Permalink
Fix apostrophes as primes
Browse files Browse the repository at this point in the history
  • Loading branch information
zblz committed Jan 19, 2016
1 parent fbb9bbc commit ffe069d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/matplotlib/mathtext.py
Expand Up @@ -2852,12 +2852,15 @@ def subsuper(self, s, loc, toks):
sub = None
super = None

# Pick all of the apostrophe's out
# Pick all of the apostrophes out, including first apostrophes that have
# been parsed as characters
napostrophes = 0
new_toks = []
for tok in toks[0]:
if isinstance(tok, six.string_types) and tok not in ('^', '_'):
napostrophes += len(tok)
elif isinstance(tok, Char) and tok.c == "'":
napostrophes += 1
else:
new_toks.append(tok)
toks = new_toks
Expand Down Expand Up @@ -2912,6 +2915,9 @@ def subsuper(self, s, loc, toks):
super = Hlist([])
for i in range(napostrophes):
super.children.extend(self.symbol(s, loc, ['\prime']))
# kern() and hpack() needed to get the metrics right after extending
super.kern()
super.hpack()

# Handle over/under symbols, such as sum or integral
if self.is_overunder(nucleus):
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_mathtext.py
Expand Up @@ -43,7 +43,7 @@
r"$\gamma = \frac{x=\frac{6}{8}}{y} \delta$",
r'$\limsup_{x\to\infty}$',
r'$\oint^\infty_0$',
r"$f'$",
r"$f'\quad f'''(x)\quad ''/\mathrm{yr}$",
r'$\frac{x_2888}{y}$',
r"$\sqrt[3]{\frac{X_2}{Y}}=5$",
r"$\sqrt[5]{\prod^\frac{x}{2\pi^2}_\infty}$",
Expand Down

0 comments on commit ffe069d

Please sign in to comment.