######################################################################### # # # # # copyright 2002 Paul Henry Tremblay # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # # General Public License for more details. # # # # # ######################################################################### import os from ebook_converter.ebooks.rtf2xml import copy from ebook_converter.ptempfile import better_mktemp from . import open_for_read, open_for_write class Footnote: """ Two public methods are available. The first separates all of the footnotes from the body and puts them at the bottom of the text, where they are easier to process. The second joins those footnotes to the proper places in the body. """ def __init__(self, in_file , bug_handler, copy=None, run_level=1, ): self.__file = in_file self.__bug_handler = bug_handler self.__copy = copy self.__write_to = better_mktemp() self.__found_a_footnote = 0 def __first_line_func(self, line): """ Print the tag info for footnotes. Check whether footnote is an endnote and make the tag according to that. """ if self.__token_info == 'cwendnote%s\n' % self.__footnote_count) else: self.__write_to_foot_obj.write( 'mi%s\n' % self.__footnote_count) self.__first_line = 0 def __in_footnote_func(self, line): """Handle all tokens that are part of footnote""" if self.__first_line: self.__first_line_func(line) if self.__token_info == 'cw