code: def foreground_chart(chart, background, colors):
      
      def convert_foreground(entry):
          try:
              attr = urwid.AttrSpec(entry, background, colors)
          except urwid.AttrSpecError:
              return None
          return attr, entry
      return parse_chart(chart, convert_foreground)
docs: Create text markup for a foreground colour chart
  
      chart -- palette chart as string
      background -- colour to use for background of chart
      colors -- number of colors (88 or 256)