@@ -2156,6 +2156,7 @@ def __init__(self):
2156
2156
p .simple = Forward ()
2157
2157
p .simple_group = Forward ()
2158
2158
p .single_symbol = Forward ()
2159
+ p .snowflake = Forward ()
2159
2160
p .space = Forward ()
2160
2161
p .sqrt = Forward ()
2161
2162
p .stackrel = Forward ()
@@ -2189,6 +2190,7 @@ def __init__(self):
2189
2190
unicode_range = "\U00000080 -\U0001ffff "
2190
2191
p .single_symbol <<= Regex (r"([a-zA-Z0-9 +\-*/<>=:,.;!\?&'@()\[\]|%s])|(\\[%%${}\[\]_|])" %
2191
2192
unicode_range )
2193
+ p .snowflake <<= Suppress (p .bslash ) + oneOf (self ._snowflake )
2192
2194
p .symbol_name <<= (Combine (p .bslash + oneOf (list (six .iterkeys (tex2uni )))) +
2193
2195
FollowedBy (Regex ("[^A-Za-z]" ).leaveWhitespace () | StringEnd ()))
2194
2196
p .symbol <<= (p .single_symbol | p .symbol_name ).leaveWhitespace ()
@@ -2263,8 +2265,10 @@ def __init__(self):
2263
2265
| Error ("Expected \operatorname{value}" ))
2264
2266
)
2265
2267
2266
- p .placeable <<= ( p .symbol # Must be first
2267
- | p .accent # Must be second
2268
+ p .placeable <<= ( p .snowflake # this needs to be before accent so named symbols
2269
+ # that are prefixed with an accent name work
2270
+ | p .accent # Must be before symbol as all accents are symbols
2271
+ | p .symbol # Must be third to catch all named symbols and single chars not in a group
2268
2272
| p .c_over_c
2269
2273
| p .function
2270
2274
| p .group
@@ -2471,6 +2475,8 @@ def symbol(self, s, loc, toks):
2471
2475
do_kern = False )]
2472
2476
return [char ]
2473
2477
2478
+ snowflake = symbol
2479
+
2474
2480
def unknown_symbol (self , s , loc , toks ):
2475
2481
# print "symbol", toks
2476
2482
c = toks [0 ]
@@ -2526,9 +2532,9 @@ def c_over_c(self, s, loc, toks):
2526
2532
r'bar' : r'\combiningoverline' ,
2527
2533
r'grave' : r'\combininggraveaccent' ,
2528
2534
r'acute' : r'\combiningacuteaccent' ,
2529
- r'ddot' : r'\combiningdiaeresis' ,
2530
2535
r'tilde' : r'\combiningtilde' ,
2531
2536
r'dot' : r'\combiningdotabove' ,
2537
+ r'ddot' : r'\combiningdiaeresis' ,
2532
2538
r'vec' : r'\combiningrightarrowabove' ,
2533
2539
r'"' : r'\combiningdiaeresis' ,
2534
2540
r"`" : r'\combininggraveaccent' ,
@@ -2543,6 +2549,11 @@ def c_over_c(self, s, loc, toks):
2543
2549
2544
2550
_wide_accents = set (r"widehat widetilde widebar" .split ())
2545
2551
2552
+ # make a lambda and call it to get the namespace right
2553
+ _snowflake = (lambda am : [p for p in tex2uni if
2554
+ any (p .startswith (a ) and a != p for a in am )]
2555
+ ) (set (_accent_map ))
2556
+
2546
2557
def accent (self , s , loc , toks ):
2547
2558
assert (len (toks )== 1 )
2548
2559
state = self .get_state ()
0 commit comments