Skip to content

mathtext: Fix bugs in conversion of apostrophes to primes #5880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/matplotlib/mathtext.py
Original file line number Diff line number Diff line change
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
231 changes: 214 additions & 17 deletions lib/matplotlib/tests/baseline_images/test_mathtext/mathtext_cm_31.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading