@@ -2190,6 +2190,7 @@ def __init__(self):
2190
2190
p .simple = Forward ()
2191
2191
p .simple_group = Forward ()
2192
2192
p .single_symbol = Forward ()
2193
+ p .snowflake = Forward ()
2193
2194
p .space = Forward ()
2194
2195
p .sqrt = Forward ()
2195
2196
p .stackrel = Forward ()
@@ -2223,6 +2224,7 @@ def __init__(self):
2223
2224
unicode_range = "\U00000080 -\U0001ffff "
2224
2225
p .single_symbol <<= Regex (r"([a-zA-Z0-9 +\-*/<>=:,.;!\?&'@()\[\]|%s])|(\\[%%${}\[\]_|])" %
2225
2226
unicode_range )
2227
+ p .snowflake <<= Suppress (p .bslash ) + oneOf (self ._snowflake )
2226
2228
p .symbol_name <<= (Combine (p .bslash + oneOf (list (six .iterkeys (tex2uni )))) +
2227
2229
FollowedBy (Regex ("[^A-Za-z]" ).leaveWhitespace () | StringEnd ()))
2228
2230
p .symbol <<= (p .single_symbol | p .symbol_name ).leaveWhitespace ()
@@ -2297,8 +2299,10 @@ def __init__(self):
2297
2299
| Error ("Expected \operatorname{value}" ))
2298
2300
)
2299
2301
2300
- p .placeable <<= ( p .symbol # Must be first
2301
- | p .accent # Must be second
2302
+ p .placeable <<= ( p .snowflake # this needs to be before accent so named symbols
2303
+ # that are prefixed with an accent name work
2304
+ | p .accent # Must be before symbol as all accents are symbols
2305
+ | p .symbol # Must be third to catch all named symbols and single chars not in a group
2302
2306
| p .c_over_c
2303
2307
| p .function
2304
2308
| p .group
@@ -2505,6 +2509,8 @@ def symbol(self, s, loc, toks):
2505
2509
do_kern = False )]
2506
2510
return [char ]
2507
2511
2512
+ snowflake = symbol
2513
+
2508
2514
def unknown_symbol (self , s , loc , toks ):
2509
2515
# print "symbol", toks
2510
2516
c = toks [0 ]
@@ -2560,9 +2566,9 @@ def c_over_c(self, s, loc, toks):
2560
2566
r'bar' : r'\combiningoverline' ,
2561
2567
r'grave' : r'\combininggraveaccent' ,
2562
2568
r'acute' : r'\combiningacuteaccent' ,
2563
- r'ddot' : r'\combiningdiaeresis' ,
2564
2569
r'tilde' : r'\combiningtilde' ,
2565
2570
r'dot' : r'\combiningdotabove' ,
2571
+ r'ddot' : r'\combiningdiaeresis' ,
2566
2572
r'vec' : r'\combiningrightarrowabove' ,
2567
2573
r'"' : r'\combiningdiaeresis' ,
2568
2574
r"`" : r'\combininggraveaccent' ,
@@ -2577,6 +2583,11 @@ def c_over_c(self, s, loc, toks):
2577
2583
2578
2584
_wide_accents = set (r"widehat widetilde widebar" .split ())
2579
2585
2586
+ # make a lambda and call it to get the namespace right
2587
+ _snowflake = (lambda am : [p for p in tex2uni if
2588
+ any (p .startswith (a ) and a != p for a in am )]
2589
+ ) (set (_accent_map ))
2590
+
2580
2591
def accent (self , s , loc , toks ):
2581
2592
assert (len (toks )== 1 )
2582
2593
state = self .get_state ()
0 commit comments