#NEWLINE# def makeFootnotesDiv( self , root ) : #NEWLINE# #INDENT# ' Return div of footnotes as et Element. ' #NEWLINE# if ( not self . footnotes . keys ( ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# div = etree . Element ( 'div' ) #NEWLINE# div . set ( 'class' , 'footnote' ) #NEWLINE# hr = etree . SubElement ( div , 'hr' ) #NEWLINE# ol = etree . SubElement ( div , 'ol' ) #NEWLINE# for id in self . footnotes . keys ( ) : #NEWLINE# #INDENT# li = etree . SubElement ( ol , 'li' ) #NEWLINE# li . set ( 'id' , self . makeFootnoteId ( id ) ) #NEWLINE# self . parser . parseChunk ( li , self . footnotes [ id ] ) #NEWLINE# backlink = etree . Element ( 'a' ) #NEWLINE# backlink . set ( 'href' , ( '#' + self . makeFootnoteRefId ( id ) ) ) #NEWLINE# backlink . set ( 'rev' , 'footnote' ) #NEWLINE# backlink . set ( 'title' , ( 'Jump back to footnote %d in the text' % ( self . footnotes . index ( id ) + 1 ) ) ) #NEWLINE# backlink . text = FN_BACKLINK_TEXT #NEWLINE# if li . getchildren ( ) : #NEWLINE# #INDENT# node = li [ ( - 1 ) ] #NEWLINE# if ( node . tag == 'p' ) : #NEWLINE# #INDENT# node . text = ( p . text + NBSP_PLACEHOLDER ) #NEWLINE# node . append ( backlink ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# p = etree . SubElement ( li , 'p' ) #NEWLINE# p . append ( backlink ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return div