@@ -791,7 +791,9 @@ def get_array(self, leaves, evaluation):
791791 raise BoxConstructError
792792 return items , options
793793
794- def boxes_to_tex (self , leaves , ** box_options ) -> str :
794+ def boxes_to_tex (self , leaves = None , ** box_options ) -> str :
795+ if not leaves :
796+ leaves = self ._leaves
795797 evaluation = box_options .get ('evaluation' )
796798 items , options = self .get_array (leaves , evaluation )
797799 new_box_options = box_options .copy ()
@@ -811,14 +813,16 @@ def boxes_to_tex(self, leaves, **box_options) -> str:
811813 column_count = max (column_count , len (row ))
812814 result = r'\begin{array}{%s} ' % (column_alignments * column_count )
813815 for index , row in enumerate (items ):
814- result += ' & ' .join (item .boxes_to_tex (** new_box_options )
816+ result += ' & ' .join (item .evaluate ( evaluation ). boxes_to_tex (** new_box_options )
815817 for item in row )
816818 if index != len (items ) - 1 :
817819 result += '\\ \\ '
818820 result += r'\end{array}'
819821 return result
820822
821- def boxes_to_xml (self , leaves , ** box_options ) -> str :
823+ def boxes_to_xml (self , leaves = None , ** box_options ) -> str :
824+ if not leaves :
825+ leaves = self ._leaves
822826 evaluation = box_options .get ('evaluation' )
823827 items , options = self .get_array (leaves , evaluation )
824828 attrs = {}
@@ -855,8 +859,7 @@ def boxes_to_text(self, leaves=None, **box_options) -> str:
855859 if not items :
856860 return ''
857861 widths = [0 ] * len (items [0 ])
858- cells = [[item .boxes_to_text (** box_options ).splitlines ()
859- for item in row ] for row in items ]
862+ cells = [[item .evaluate (evaluation ).boxes_to_text (** box_options ).splitlines () for item in row ] for row in items ]
860863 for row in cells :
861864 for index , cell in enumerate (row ):
862865 if index >= len (widths ):
@@ -907,14 +910,12 @@ class Grid(Builtin):
907910 def apply_makeboxes (self , array , f , evaluation , options ) -> Expression :
908911 '''MakeBoxes[Grid[array_?MatrixQ, OptionsPattern[Grid]],
909912 f:StandardForm|TraditionalForm|OutputForm]'''
910-
911- return Expression (
912- 'GridBox' ,
913- Expression ('List' , * (
913+ return GridBox (Expression ('List' , * (
914914 Expression ('List' , * (
915915 Expression ('MakeBoxes' , item , f ) for item in row .leaves ))
916916 for row in array .leaves )),
917917 * options_to_rules (options ))
918+ # return Expression('GridBox',Expression('List', *(Expression('List', *(Expression('MakeBoxes', item, f) for item in row.leaves)) for row in array.leaves)), *options_to_rules(options))
918919
919920
920921class TableForm (Builtin ):
@@ -974,10 +975,13 @@ def apply_makeboxes(self, table, f, evaluation, options):
974975 if depth <= 0 :
975976 return Expression ('MakeBoxes' , table , f )
976977 elif depth == 1 :
977- return Expression (
978- 'GridBox' , Expression ('List' , * (
978+ return GridBox ( Expression ('List' , * (
979979 Expression ('List' , Expression ('MakeBoxes' , item , f ))
980980 for item in table .leaves )))
981+ #return Expression(
982+ # 'GridBox', Expression('List', *(
983+ # Expression('List', Expression('MakeBoxes', item, f))
984+ # for item in table.leaves)))
981985 else :
982986 new_depth = Expression ('Rule' , Symbol ('TableDepth' ), depth - 2 )
983987
@@ -987,8 +991,7 @@ def transform_item(item):
987991 else :
988992 return item
989993
990- return Expression (
991- 'GridBox' , Expression ('List' , * (
994+ return GridBox (Expression ('List' , * (
992995 Expression ('List' , * (
993996 Expression ('MakeBoxes' , transform_item (item ), f )
994997 for item in row .leaves )) for row in table .leaves )))
@@ -2011,11 +2014,9 @@ def apply_mathml(self, expr, evaluation) -> Expression:
20112014 'MakeBoxes[expr_, MathMLForm]'
20122015
20132016 boxes = MakeBoxes (expr ).evaluate (evaluation )
2014- print ("=====MakeBoxes, MathMLForm boxes=" ,boxes )
20152017 try :
20162018 xml = boxes .boxes_to_xml (evaluation = evaluation )
20172019 except BoxError :
2018- print ("======error" )
20192020 evaluation .message (
20202021 'General' , 'notboxes' ,
20212022 Expression ('FullForm' , boxes ).evaluate (evaluation ))
0 commit comments