- """add footer
-
-also add navigation bar to bottom of Info HTML pages"""
- m = info_nav_bar.search (s)
- if m:
- # avoid duplicate <hr> in case there are footnotes at the end of the Info HTML page
- if info_footnote_hr.search (s):
- custom_footer = '<div class="node">\n<p>' + m.group (1) + '</div>\n' + footer
- else:
- custom_footer = '<br><hr>\n<div class="node">\n<p>' + m.group (1) + '</div>\n' + footer
- else:
- custom_footer = footer
- if re.search ('(?i)</body', s):
- s = re.sub ('(?i)</body>', footer_tag + custom_footer + '\n' + '</BODY>', s, 1)
- elif re.search ('(?i)</html', s):
- s = re.sub ('(?i)</html>', footer_tag + custom_footer + '\n' + '</HTML>', s, 1)
- else:
- s += footer_tag + custom_footer + '\n'
+ """add footer"""
+ (s, n) = end_body_re.subn (footer_tag + footer + '\n' + '</body>', s, 1)
+ if not n:
+ (s, n) = end_html_re.subn (footer_tag + footer + '\n' + '</html>', s, 1)
+ if not n:
+ s += footer_tag + footer + '\n'