code: def _colorformat(text):
      
      if text[0:1] == '#':
          col = text[1:]
          if col in ANSI_COLOR_NAMES:
              return col
          elif len(col) == 6:
              return col
          elif len(col) == 3:
              return col[0]*2 + col[1]*2 + col[2]*2
      elif text == '':
          return text
  
      raise ValueError('Wrong color format %r' % text)
docs: Parse/validate color format.
  
      Like in Pygments, but also support the ANSI color names.
      (These will map to the colors of the 16 color palette.)