docstr: ### Add ansi color codes
docstr_tok: ["#","#","#","Add","ansi","color","codes"]
code: def html_code(text: str, color: List[StyleCode] or StyleCode or None):
      """
      ### Add ansi color codes
      """
      if text == "\n":
          assert color is None
          return text
  
      if color is None:
          return text
      elif isinstance(color, list):
          open_tags = "".join([c.html_open(text) for c in color])
          close_tags = "".join(
              [c.html_close(text) for c in reversed(color)]
          )
      else:
          open_tags = color.html_open(text)
          close_tags = color.html_close(text)
  
      return open_tags + text + close_tags
  
file_path: labml/client/labml/internal/logger/destinations/ipynb.py
imports: import threading
  from typing import List, Union, Tuple, Callable, Optional
  from IPython.core.display import display, HTML
  from labml.internal.logger.destinations import Destination
  from labml.internal.util import is_kaggle
  from labml.internal.util.colors import StyleCode
label_desc: Use image node_id 3 for calling the IpynbDestination obj's underlying member method code with example usage: obj.html_code(text, color) and returns: unknown, text, text