from HTMLParser import HTMLParser
import re
def bfs10205(bfs10204):
  s = bfs10203()
  s.feed(bfs10204)
  return s.get_data()

class bfs10203(HTMLParser):
  def __init__(self):
    HTMLParser.__init__(self)
    self.reset()
    self.bfs10206 = []

  def handle_data(self, d):
    self.bfs10206.append(d)

  def get_data(self):
    return ''.join(self.bfs10206)


def bfs10216(bfs10207):
  bfs10207 = bfs10210(bfs10207)
  try:
    bfs10212 = (bfs10207.index('>') + 1)
    bfs10211 = bfs10207.rindex('<', bfs10212)
  except ValueError:
    return bfs10207

  bfs10213 = bfs10207[:bfs10212]
  bfs10215 = bfs10207[bfs10211:]
  bfs10214 = bfs10207[bfs10212:bfs10211]
  if (('<' in bfs10214) or (len(bfs10214) > 60)):
    return ('%s...%s' % (bfs10213, bfs10215))
  else:
    return bfs10207


def bfs10210(bfs10220):
  bfs10217 = bfs10220.strip()
  bfs10217 = re.sub('\\s+', ' ', bfs10217)
  bfs10217 = bfs10217.replace('> ', '>').replace(' <', '<')
  return bfs10217

