@@ -123,7 +123,8 @@ def add_step(self,
123123 variables : Dict [str , Any ],
124124 message : str = "" ,
125125 highlight : List [int ] = None ,
126- current : List [int ] = None ):
126+ current : List [int ] = None ,
127+ notToHighlight = []):
127128 """
128129 Save a step in your algorithm for visualization.
129130
@@ -160,9 +161,10 @@ def add_step(self,
160161 step_data = {
161162 'variables' : variables .copy (),
162163 'message' : message ,
163- 'highlight' : highlight . copy () ,
164+ 'highlight' : highlight ,
164165 'current' : current .copy (),
165- 'step_number' : len (self .steps )
166+ 'step_number' : len (self .steps ),
167+ "notToHighlight" : notToHighlight ,
166168 }
167169 self .steps .append (step_data )
168170
@@ -220,7 +222,7 @@ def save(self, filename: str) -> str:
220222 print (f"💾 Visualization saved to { filename } " )
221223 return filename
222224
223- def _render_variable (self , name : str , value : Any , highlight : List [int ] = None , current : List [int ] = None ) -> str :
225+ def _render_variable (self , name : str , value : Any , highlight : List [int ] = None , current : List [int ] = None , notToHighlight = [] ) -> str :
224226 """Convert a variable to HTML representation."""
225227 if highlight is None :
226228 highlight = []
@@ -229,7 +231,7 @@ def _render_variable(self, name: str, value: Any, highlight: List[int] = None, c
229231
230232 # Handle different data types
231233 if isinstance (value , (list , tuple )):
232- return self ._render_array (name , value , highlight , current )
234+ return self ._render_array (name , value , highlight if value not in notToHighlight else [] , current )
233235 elif isinstance (value , dict ):
234236 return self ._render_dict (name , value )
235237 elif isinstance (value , (int , float , str , bool )):
@@ -295,7 +297,7 @@ def _generate_html(self) -> str:
295297 # Render all variables in this step
296298 variables_html = []
297299 for var_name , var_value in step ['variables' ].items ():
298- var_html = self ._render_variable (var_name , var_value , step ['highlight' ], step ['current' ])
300+ var_html = self ._render_variable (var_name , var_value , step ['highlight' ], step ['current' ], notToHighlight = step [ 'notToHighlight' ] )
299301 variables_html .append (var_html )
300302
301303 js_steps .append ({
0 commit comments