@@ -2365,16 +2365,16 @@ def _make_space(self, percentage):
23652365 }
23662366
23672367 def space (self , s , loc , toks ):
2368- assert len ( toks ) == 1
2369- num = self ._space_widths [toks [ 0 ] ]
2368+ tok , = toks
2369+ num = self ._space_widths [tok ]
23702370 box = self ._make_space (num )
23712371 return [box ]
23722372
23732373 def customspace (self , s , loc , toks ):
23742374 return [self ._make_space (float (toks [0 ]))]
23752375
23762376 def symbol (self , s , loc , toks ):
2377- c = toks [ 0 ]
2377+ c , = toks
23782378 try :
23792379 char = Char (c , self .get_state ())
23802380 except ValueError as err :
@@ -2414,7 +2414,7 @@ def symbol(self, s, loc, toks):
24142414 accentprefixed = symbol
24152415
24162416 def unknown_symbol (self , s , loc , toks ):
2417- c = toks [ 0 ]
2417+ c , = toks
24182418 raise ParseFatalException (s , loc , "Unknown symbol: %s" % c )
24192419
24202420 _char_over_chars = {
@@ -2425,7 +2425,7 @@ def unknown_symbol(self, s, loc, toks):
24252425 }
24262426
24272427 def c_over_c (self , s , loc , toks ):
2428- sym = toks [ 0 ]
2428+ sym , = toks
24292429 state = self .get_state ()
24302430 thickness = state .font_output .get_underline_thickness (
24312431 state .font , state .fontsize , state .dpi )
@@ -2491,13 +2491,10 @@ def c_over_c(self, s, loc, toks):
24912491 ])(set (_accent_map ))
24922492
24932493 def accent (self , s , loc , toks ):
2494- assert len (toks ) == 1
24952494 state = self .get_state ()
24962495 thickness = state .font_output .get_underline_thickness (
24972496 state .font , state .fontsize , state .dpi )
2498- if len (toks [0 ]) != 2 :
2499- raise ParseFatalException ("Error parsing accent" )
2500- accent , sym = toks [0 ]
2497+ (accent , sym ), = toks
25012498 if accent in self ._wide_accents :
25022499 accent_box = AutoWidthChar (
25032500 '\\ ' + accent , sym .width , state , char_class = Accent )
@@ -2516,7 +2513,7 @@ def accent(self, s, loc, toks):
25162513
25172514 def function (self , s , loc , toks ):
25182515 hlist = self .operatorname (s , loc , toks )
2519- hlist .function_name = toks [ 0 ]
2516+ hlist .function_name , = toks
25202517 return hlist
25212518
25222519 def operatorname (self , s , loc , toks ):
@@ -2564,8 +2561,7 @@ def end_group(self, s, loc, toks):
25642561 return []
25652562
25662563 def font (self , s , loc , toks ):
2567- assert len (toks ) == 1
2568- name = toks [0 ]
2564+ name , = toks
25692565 self .get_state ().font = name
25702566 return []
25712567
@@ -2821,45 +2817,32 @@ def _genfrac(self, ldelim, rdelim, rule, style, num, den):
28212817 return result
28222818
28232819 def genfrac (self , s , loc , toks ):
2824- assert len (toks ) == 1
2825- assert len (toks [0 ]) == 6
2826-
2827- return self ._genfrac (* tuple (toks [0 ]))
2820+ args , = toks
2821+ return self ._genfrac (* args )
28282822
28292823 def frac (self , s , loc , toks ):
2830- assert len (toks ) == 1
2831- assert len (toks [0 ]) == 2
28322824 state = self .get_state ()
2833-
28342825 thickness = state .font_output .get_underline_thickness (
28352826 state .font , state .fontsize , state .dpi )
2836- num , den = toks [0 ]
2837-
2827+ (num , den ), = toks
28382828 return self ._genfrac ('' , '' , thickness , self ._MathStyle .TEXTSTYLE ,
28392829 num , den )
28402830
28412831 def dfrac (self , s , loc , toks ):
2842- assert len (toks ) == 1
2843- assert len (toks [0 ]) == 2
28442832 state = self .get_state ()
2845-
28462833 thickness = state .font_output .get_underline_thickness (
28472834 state .font , state .fontsize , state .dpi )
2848- num , den = toks [0 ]
2849-
2835+ (num , den ), = toks
28502836 return self ._genfrac ('' , '' , thickness , self ._MathStyle .DISPLAYSTYLE ,
28512837 num , den )
28522838
28532839 def binom (self , s , loc , toks ):
2854- assert len (toks ) == 1
2855- assert len (toks [0 ]) == 2
2856- num , den = toks [0 ]
2857-
2840+ (num , den ), = toks
28582841 return self ._genfrac ('(' , ')' , 0.0 , self ._MathStyle .TEXTSTYLE ,
28592842 num , den )
28602843
28612844 def sqrt (self , s , loc , toks ):
2862- root , body = toks [ 0 ]
2845+ ( root , body ), = toks
28632846 state = self .get_state ()
28642847 thickness = state .font_output .get_underline_thickness (
28652848 state .font , state .fontsize , state .dpi )
@@ -2899,10 +2882,7 @@ def sqrt(self, s, loc, toks):
28992882 return [hlist ]
29002883
29012884 def overline (self , s , loc , toks ):
2902- assert len (toks ) == 1
2903- assert len (toks [0 ]) == 1
2904-
2905- body = toks [0 ][0 ]
2885+ (body ,), = toks
29062886
29072887 state = self .get_state ()
29082888 thickness = state .font_output .get_underline_thickness (
0 commit comments