######################################################################### # # # # # 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. # # # # You should have received a copy of the GNU General Public License # # along with this program; if not, write to the Free Software # # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # # 02111-1307 USA # # # # # ######################################################################### import os, tempfile from libprs500.ebooks.rtf2xml import copy 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 = tempfile.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