#NEWLINE# def run( state_machine ) : #NEWLINE# #INDENT# def get_n( n , l ) : #NEWLINE# #INDENT# part = [ ] #NEWLINE# for x in l : #NEWLINE# #INDENT# part . append ( x ) #NEWLINE# if ( len ( part ) == n ) : #NEWLINE# #INDENT# ( yield part ) #NEWLINE# part = [ ] #NEWLINE# #UNINDENT# #UNINDENT# ( yield part ) #NEWLINE# #UNINDENT# lines = [ ] #NEWLINE# for ( category , columns , syms ) in symbols : #NEWLINE# #INDENT# syms = syms . split ( ) #NEWLINE# syms . sort ( ) #NEWLINE# lines . append ( ( '**%s**' % category ) ) #NEWLINE# lines . append ( '' ) #NEWLINE# max_width = 0 #NEWLINE# for sym in syms : #NEWLINE# #INDENT# max_width = max ( max_width , len ( sym ) ) #NEWLINE# #UNINDENT# max_width = ( ( max_width * 2 ) + 16 ) #NEWLINE# header = ( '    ' + ( ( ( '=' * max_width ) + ' ' ) * columns ) ) #NEWLINE# format = ( '%%%ds' % max_width ) #NEWLINE# for chunk in get_n ( 20 , get_n ( columns , syms ) ) : #NEWLINE# #INDENT# lines . append ( header ) #NEWLINE# for part in chunk : #NEWLINE# #INDENT# line = [ ] #NEWLINE# for sym in part : #NEWLINE# #INDENT# line . append ( ( format % ( ':math:`%s` ``%s``' % ( sym , sym ) ) ) ) #NEWLINE# #UNINDENT# lines . append ( ( '    ' + ' ' . join ( line ) ) ) #NEWLINE# #UNINDENT# lines . append ( format ) #NEWLINE# lines . append ( '' ) #NEWLINE# #UNINDENT# #UNINDENT# state_machine . insert_input ( lines , 'Symbol table' ) #NEWLINE# return [ ]