def putInToC(document, toc):
 tocOrig = domhelpers.findElementsWithAttribute(document, 'class', 'toc')
 if tocOrig:
  tocOrig = tocOrig[0]
  tocOrig.childNodes = [toc]

def putInToC ( document , toc ) : tocOrig = domhelpers . findElementsWithAttribute ( document , 'class' , 'toc' ) if tocOrig : tocOrig = tocOrig [ 0 ] tocOrig . childNodes = [ toc ]
insert the given table of contents into the given document .