def tidy_fragment(text, options=None, keep_doc=False):
 (document, errors) = tidy_document(text, options, keep_doc)
 match = RE_BODY.search(document)
 if match:
  document = match.group(1).strip()
  return (document, errors)
 else:
  raise ValueError('tidy_fragment failed to process text')

def tidy_fragment ( text , options = None , keep_doc = False ) : ( document , errors ) = tidy_document ( text , options , keep_doc ) match = RE_BODY . search ( document ) if match : document = match . group ( 1 ) . strip ( ) return ( document , errors ) else : raise ValueError ( 'tidy_fragment failed to process text' )
tidy a string with markup and return only the <body> contents .