FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

mathtext-prime by mdboom · Pull Request #836 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .pdf  (3) .png  (1) .py  (3) .svg  (3) All 4 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 3 additions & 1 deletion lib/matplotlib/_mathtext_data.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@
r'\Psi' : ('cmr10', 15),
r'\Omega' : ('cmr10', 12),

r'\prime' : ('cmsy10', 73),

# these are mathml names, I think. I'm just using them for the
# tex methods noted
r'\circumflexaccent' : ('cmr10', 124), # for \hat
Expand Down Expand Up @@ -245,7 +247,7 @@
r'\spadesuit' : ('cmsy10', 7),
r'?' : ('cmr10', 50),
r'!' : ('cmr10', 29),
r'&' : ('cmr10', 109)
r'&' : ('cmr10', 109)
}

latex_to_cmex = {
Expand Down
48 changes: 36 additions & 12 deletions lib/matplotlib/mathtext.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2179,13 +2179,15 @@ def __init__(self):
).setParseAction(self.customspace).setName('customspace')

unicode_range = u"\U00000080-\U0001ffff"
symbol =(Regex(UR"([a-zA-Z0-9 +\-*/<>=:,.;!\?&'@()\[\]|%s])|(\\[%%${}\[\]_|])" % unicode_range)
symbol =(Regex(UR"([a-zA-Z0-9 +\-*/<>=:,.;!\?&@()\[\]|%s])|(\\[%%${}\[\]_|])" % unicode_range)
| (Combine(
bslash
+ oneOf(tex2uni.keys())
) + FollowedBy(Regex("[^a-zA-Z]")))
).setParseAction(self.symbol).leaveWhitespace()

apostrophe = Regex(r"'+")

c_over_c =(Suppress(bslash)
+ oneOf(self._char_over_chars.keys())
).setParseAction(self.char_over_chars)
Expand Down Expand Up @@ -2296,8 +2298,10 @@ def __init__(self):
subsuperop
- placeable
)
+ Optional(apostrophe)
)
| placeable
| (placeable + Optional(apostrophe))
| apostrophe
)

autoDelim <<(Suppress(Literal(r"\left"))
Expand Down Expand Up @@ -2464,8 +2468,6 @@ def customspace(self, s, loc, toks):
def symbol(self, s, loc, toks):
# print "symbol", toks
c = toks[0]
if c == "'":
c = '\prime'
try:
char = Char(c, self.get_state())
except ValueError:
Expand Down Expand Up @@ -2625,23 +2627,39 @@ def subsuperscript(self, s, loc, toks):
sub = None
super = None

if len(toks[0]) == 1:
return toks[0].asList()
elif len(toks[0]) == 2:
op, next = toks[0]
# Pick all of the apostrophe's out
napostrophes = 0
new_toks = []
for tok in toks[0]:
if isinstance(tok, str) and tok not in ('^', '_'):
napostrophes += len(tok)
else:
new_toks.append(tok)
toks = new_toks

if len(toks) == 0:
assert napostrophes
nucleus = Hbox(0.0)
elif len(toks) == 1:
if not napostrophes:
return toks[0] # .asList()
else:
nucleus = toks[0]
elif len(toks) == 2:
op, next = toks
nucleus = Hbox(0.0)
if op == '_':
sub = next
else:
super = next
elif len(toks[0]) == 3:
nucleus, op, next = toks[0]
elif len(toks) == 3:
nucleus, op, next = toks
if op == '_':
sub = next
else:
super = next
elif len(toks[0]) == 5:
nucleus, op1, next1, op2, next2 = toks[0]
elif len(toks) == 5:
nucleus, op1, next1, op2, next2 = toks
if op1 == op2:
if op1 == '_':
raise ParseFatalException("Double subscript")
Expand All @@ -2664,6 +2682,12 @@ def subsuperscript(self, s, loc, toks):
xHeight = state.font_output.get_xheight(
state.font, state.fontsize, state.dpi)

if napostrophes:
if super is None:
super = Hlist([])
for i in range(napostrophes):
super.children.extend(self.symbol(s, loc, ['\prime']))

# Handle over/under symbols, such as sum or integral
if self.is_overunder(nucleus):
vlist = []
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.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Binary file not shown.
Loading

Back | FazBrowse Home | New Git URL