diff --git a/src/BaseDoc.py b/src/BaseDoc.py index 4495c1a17..fee834117 100644 --- a/src/BaseDoc.py +++ b/src/BaseDoc.py @@ -1402,6 +1402,7 @@ class BaseDoc: "Closes the document" raise NotImplementedError + #------------------------------------------------------------------------ # # TextDoc @@ -1552,6 +1553,36 @@ class TextDoc: """ text = str(styledtext) self.write_note(text, format, style_name) + + def write_text_citation(self, text, mark=None): + """Method to write text with GRAMPS citation marks""" + if not text: + return + parts = text.split("") + markset = False + for piece in parts: + if not piece: + # a text 'text ...' splits as '', 'text..' + continue + piecesplit = piece.split("") + if len(piecesplit) == 2: + self.start_superscript() + self.write_text(piecesplit[0]) + self.end_superscript() + if not piecesplit[1]: + #text ended with ' ... ' + continue + if not markset: + self.write_text(piecesplit[1], mark) + markset = True + else: + self.write_text(piecesplit[1]) + else: + if not markset: + self.write_text(piece, mark) + markset = True + else: + self.write_text(piece) def add_media_object(self, name, align, w_cm, h_cm): """ diff --git a/src/plugins/docgen/AsciiDoc.py b/src/plugins/docgen/AsciiDoc.py index 6446fc11e..f716d4501 100644 --- a/src/plugins/docgen/AsciiDoc.py +++ b/src/plugins/docgen/AsciiDoc.py @@ -3,6 +3,7 @@ # # Copyright (C) 2000-2006 Donald N. Allingham # Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2009 Benny Malengier # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -362,8 +363,6 @@ class AsciiDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): # Writes text. #-------------------------------------------------------------------- def write_text(self,text,mark=None): - text = text.replace('','[') - text = text.replace('',']') self.text = self.text + text #------------------------------------------------------------------------ diff --git a/src/plugins/docgen/CairoDoc.py b/src/plugins/docgen/CairoDoc.py index b23e84f3b..e123d04b6 100644 --- a/src/plugins/docgen/CairoDoc.py +++ b/src/plugins/docgen/CairoDoc.py @@ -1073,8 +1073,8 @@ class CairoDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc): BaseDoc.TextDoc.FONTSIZE : 'size', } - # overwrite base class attributes - BaseDoc.TextDoc.SUPPORTED_MARKUP = [ + # overwrite base class attributes, they become static var of CairoDoc + SUPPORTED_MARKUP = [ BaseDoc.TextDoc.BOLD, BaseDoc.TextDoc.ITALIC, BaseDoc.TextDoc.UNDERLINE, @@ -1084,14 +1084,14 @@ class CairoDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc): BaseDoc.TextDoc.HIGHLIGHT, BaseDoc.TextDoc.SUPERSCRIPT ] - BaseDoc.TextDoc.STYLETAG_MARKUP = { + STYLETAG_MARKUP = { BaseDoc.TextDoc.BOLD : ("", ""), BaseDoc.TextDoc.ITALIC : ("", ""), BaseDoc.TextDoc.UNDERLINE : ("", ""), BaseDoc.TextDoc.SUPERSCRIPT : ("", ""), } - BaseDoc.TextDoc.ESCAPE_FUNC = lambda x: escape + ESCAPE_FUNC = lambda x: escape # BaseDoc implementation diff --git a/src/plugins/docgen/HtmlDoc.py b/src/plugins/docgen/HtmlDoc.py index 83505c452..17159cd9e 100644 --- a/src/plugins/docgen/HtmlDoc.py +++ b/src/plugins/docgen/HtmlDoc.py @@ -3,6 +3,7 @@ # # Copyright (C) 2000-2006 Donald N. Allingham # Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2009 Benny Malengier # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -464,8 +465,6 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): text = text.replace('<','<'); text = text.replace('>','>'); text = text.replace('\n','
') - text = text.replace('<super>','') - text = text.replace('</super>','') if text != "": self.empty = 0 self.f.write(text) diff --git a/src/plugins/docgen/LaTeXDoc.py b/src/plugins/docgen/LaTeXDoc.py index bc9abe0c6..c118d379b 100644 --- a/src/plugins/docgen/LaTeXDoc.py +++ b/src/plugins/docgen/LaTeXDoc.py @@ -168,8 +168,8 @@ def latexescapeverbatim(text): class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): """LaTeX document interface class. Derived from BaseDoc""" - # overwrite base class attributes - BaseDoc.TextDoc.SUPPORTED_MARKUP = [ + # overwrite base class attributes, they become static var of LaTeXDoc + SUPPORTED_MARKUP = [ BaseDoc.TextDoc.BOLD, BaseDoc.TextDoc.ITALIC, BaseDoc.TextDoc.UNDERLINE, @@ -177,14 +177,14 @@ class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): BaseDoc.TextDoc.FONTFACE, BaseDoc.TextDoc.SUPERSCRIPT ] - BaseDoc.TextDoc.STYLETAG_MARKUP = { + STYLETAG_MARKUP = { BaseDoc.TextDoc.BOLD : ("\\textbf{", "}"), BaseDoc.TextDoc.ITALIC : ("\\textit{", "}"), BaseDoc.TextDoc.UNDERLINE : ("\\underline{", "}"), BaseDoc.TextDoc.SUPERSCRIPT : ("\\textsuperscript{", "}"), } - BaseDoc.TextDoc.ESCAPE_FUNC = lambda x: latexescape + ESCAPE_FUNC = lambda x: latexescape def page_break(self): "Forces a page break, creating a new page" @@ -553,7 +553,8 @@ class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): text = '\\newline\n' text = latexescape(text) #hard coded replace of the underline used for missing names/data - text = text.replace('\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_','\\underline{\hspace{3cm}}') + text = text.replace('\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_\\_', + '\\underline{\hspace{3cm}}') self.f.write(text) def write_styled_note(self, styledtext, format, style_name): diff --git a/src/plugins/docgen/ODFDoc.py b/src/plugins/docgen/ODFDoc.py index 87acc7c3b..f04fe6a69 100644 --- a/src/plugins/docgen/ODFDoc.py +++ b/src/plugins/docgen/ODFDoc.py @@ -67,9 +67,7 @@ _esc_map = { '\x1a' : '', '\x0c' : '', '\n' : '', - '\t' : '', - '<super>' : '', - '</super>' : '', + '\t' : '', } #------------------------------------------------------------------------- diff --git a/src/plugins/docgen/RTFDoc.py b/src/plugins/docgen/RTFDoc.py index b11836b4f..43a84da28 100644 --- a/src/plugins/docgen/RTFDoc.py +++ b/src/plugins/docgen/RTFDoc.py @@ -430,9 +430,6 @@ class RTFDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): else: self.text = self.text + i - self.text = self.text.replace('','{{\*\updnprop5801}\up10 ') - self.text = self.text.replace('','}') - #------------------------------------------------------------------------ # # Register the document generator with the GRAMPS plugin system diff --git a/src/plugins/textreport/DetAncestralReport.py b/src/plugins/textreport/DetAncestralReport.py index ae5092520..ad775a2ee 100644 --- a/src/plugins/textreport/DetAncestralReport.py +++ b/src/plugins/textreport/DetAncestralReport.py @@ -5,6 +5,7 @@ # Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2007-2008 Brian G. Matherly # Copyright (C) 2008 James Friedmann +# Copyright (C) 2009 Benny Malengier # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -209,9 +210,9 @@ class DetAncestorReport(Report): self.doc.start_bold() self.doc.write_text(name,mark) if name[-1:] == '.': - self.doc.write_text("%s " % self.endnotes(person)) + self.doc.write_text_citation("%s " % self.endnotes(person)) else: - self.doc.write_text("%s. " % self.endnotes(person)) + self.doc.write_text_citation("%s. " % self.endnotes(person)) self.doc.end_bold() if self.dupperson: @@ -243,18 +244,18 @@ class DetAncestorReport(Report): birth = self.database.get_event_from_handle(birth_ref.ref) text = text.rstrip(". ") text = text + self.endnotes(birth) + ". " - self.doc.write_text(text) + self.doc.write_text_citation(text) first = 0 text = ReportUtils.baptised_str(self.database, person, first, self.verbose, self.endnotes, self.EMPTY_DATE, self.EMPTY_PLACE) if text: - self.doc.write_text(text) + self.doc.write_text_citation(text) text = ReportUtils.christened_str(self.database, person, first, self.verbose, self.endnotes, self.EMPTY_DATE, self.EMPTY_PLACE) if text: - self.doc.write_text(text) + self.doc.write_text_citation(text) span = self.calc_age(person) text = ReportUtils.died_str(self.database, person, first, self.verbose, @@ -265,13 +266,13 @@ class DetAncestorReport(Report): death = self.database.get_event_from_handle(death_ref.ref) text = text.rstrip(". ") text = text + self.endnotes(death) + ". " - self.doc.write_text(text) + self.doc.write_text_citation(text) first = 0 text = ReportUtils.buried_str(self.database, person, first, self.verbose, self.endnotes, self.EMPTY_DATE, self.EMPTY_PLACE) if text: - self.doc.write_text(text) + self.doc.write_text_citation(text) first = ReportUtils.common_name(person,self.usecall) @@ -306,7 +307,7 @@ class DetAncestorReport(Report): first = False self.doc.start_paragraph('DAR-MoreDetails') atype = str( alt_name.get_type() ) - self.doc.write_text( + self.doc.write_text_citation( _('%(name_kind)s: %(name)s%(endnotes)s') % { 'name_kind' : atype, 'name' : alt_name.get_regular_name(), @@ -346,7 +347,7 @@ class DetAncestorReport(Report): if date: self.doc.write_text( '%s, ' % date ) self.doc.write_text( text ) - self.doc.write_text( self.endnotes(addr) ) + self.doc.write_text_citation( self.endnotes(addr) ) self.doc.end_paragraph() if self.inc_attrs: @@ -364,7 +365,7 @@ class DetAncestorReport(Report): 'type' : attr.get_type(), 'value' : attr.get_value(), 'endnotes' : self.endnotes(attr) } - self.doc.write_text( text ) + self.doc.write_text_citation( text ) self.doc.end_paragraph() return 0 # Not duplicate person @@ -403,7 +404,7 @@ class DetAncestorReport(Report): 'event_name' : _(evtName), 'event_text' : text } - self.doc.write_text(text) + self.doc.write_text_citation(text) if self.inc_attrs: text = "" @@ -417,7 +418,7 @@ class DetAncestorReport(Report): 'value' : attr.get_value(), 'endnotes' : self.endnotes(attr) } text = " " + text - self.doc.write_text(text) + self.doc.write_text_citation(text) self.doc.end_paragraph() @@ -428,9 +429,8 @@ class DetAncestorReport(Report): notelist.extend(event_ref.get_note_list()) for notehandle in notelist: note = self.database.get_note_from_handle(notehandle) - self.doc.start_paragraph('DAR-MoreDetails') - self.doc.write_text(note.get()) - self.doc.end_paragraph() + self.doc.write_styled_note(note.get_styledtext(), + note.get_format(),"DAR-MoreDetails") def write_parents(self, person, firstName): family_handle = person.get_main_parents_family_handle() @@ -482,7 +482,7 @@ class DetAncestorReport(Report): is_first) if text: - self.doc.write_text(text,spouse_mark) + self.doc.write_text_citation(text,spouse_mark) is_first = False def write_children(self, family): @@ -614,9 +614,9 @@ class DetAncestorReport(Report): self.doc.write_text(name, mark) if name[-1:] == '.': - self.doc.write_text("%s " % self.endnotes(ind)) + self.doc.write_text_citation("%s " % self.endnotes(ind)) else: - self.doc.write_text("%s. " % self.endnotes(ind)) + self.doc.write_text_citation("%s. " % self.endnotes(ind)) first_name = ReportUtils.common_name(ind, self.usecall) print_name = first_name @@ -631,7 +631,7 @@ class DetAncestorReport(Report): self.verbose, self.endnotes, self.EMPTY_DATE, self.EMPTY_PLACE) if text: - self.doc.write_text(text) + self.doc.write_text_citation(text) print_name = 0 span = self.calc_age(ind) @@ -647,7 +647,7 @@ class DetAncestorReport(Report): self.EMPTY_PLACE) if text: - self.doc.write_text(text) + self.doc.write_text_citation(text) print_name = 0 if print_name == 0: diff --git a/src/plugins/textreport/DetDescendantReport.py b/src/plugins/textreport/DetDescendantReport.py index e4487aa6a..62aa08c34 100644 --- a/src/plugins/textreport/DetDescendantReport.py +++ b/src/plugins/textreport/DetDescendantReport.py @@ -6,6 +6,7 @@ # Copyright (C) 2007-2008 Brian G. Matherly # Copyright (C) 2007 Robert Cawley # Copyright (C) 2008-2009 James Friedmann +# Copyright (C) 2009 Benny Malengier # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -245,9 +246,9 @@ class DetDescendantReport(Report): self.doc.start_bold() self.doc.write_text(name, mark) if name[-1:] == '.': - self.doc.write_text("%s " % self.endnotes(person)) + self.doc.write_text_citation("%s " % self.endnotes(person)) else: - self.doc.write_text("%s. " % self.endnotes(person)) + self.doc.write_text_citation("%s. " % self.endnotes(person)) self.doc.end_bold() if self.dubperson: @@ -325,7 +326,7 @@ class DetDescendantReport(Report): 'value' : attr.get_value(), 'endnotes' : self.endnotes(attr) } text = " " + text - self.doc.write_text(text) + self.doc.write_text_citation(text) self.doc.end_paragraph() @@ -336,9 +337,8 @@ class DetDescendantReport(Report): notelist.extend(event_ref.get_note_list()) for notehandle in notelist: note = self.database.get_note_from_handle(notehandle) - self.doc.start_paragraph('DDR-MoreDetails') - self.doc.write_text(note.get()) - self.doc.end_paragraph() + self.doc.write_styled_note(note.get_styledtext(), + note.get_format(),"DDR-MoreDetails") def write_parents(self, person, firstName): family_handle = person.get_main_parents_family_handle() @@ -390,7 +390,7 @@ class DetDescendantReport(Report): is_first) if text: - self.doc.write_text(text, spouse_mark) + self.doc.write_text_citation(text, spouse_mark) is_first = False def __write_mate(self, person, family): @@ -414,7 +414,7 @@ class DetDescendantReport(Report): self.doc.write_text(_("Relationship with: %s") % name, mark) if name[-1:] != '.': self.doc.write_text(".") - self.doc.write_text(self.endnotes(mate)) + self.doc.write_text_citation(self.endnotes(mate)) self.doc.end_paragraph() self.write_person_info(mate) @@ -532,20 +532,20 @@ class DetDescendantReport(Report): birth = self.database.get_event_from_handle(birth_ref.ref) text = text.rstrip(". ") text = text + self.endnotes(birth) + ". " - self.doc.write_text(text) + self.doc.write_text_citation(text) first = 0 text = ReportUtils.baptised_str(self.database, person, first, self.verbose, self.endnotes, self.EMPTY_DATE, self.EMPTY_PLACE) if text: - self.doc.write_text(text) + self.doc.write_text_citation(text) text = ReportUtils.christened_str(self.database, person, first, self.verbose, self.endnotes, self.EMPTY_DATE, self.EMPTY_PLACE) if text: - self.doc.write_text(text) + self.doc.write_text_citation(text) span = self.calc_age(person) text = ReportUtils.died_str(self.database, person, first, self.verbose, @@ -556,14 +556,14 @@ class DetDescendantReport(Report): death = self.database.get_event_from_handle(death_ref.ref) text = text.rstrip(". ") text = text + self.endnotes(death) + ". " - self.doc.write_text(text) + self.doc.write_text_citation(text) first = 0 text = ReportUtils.buried_str(self.database, person, first, self.verbose, self.endnotes, self.EMPTY_DATE, self.EMPTY_PLACE) if text: - self.doc.write_text(text) + self.doc.write_text_citation(text) first = ReportUtils.common_name(person, self.usecall) @@ -594,7 +594,7 @@ class DetDescendantReport(Report): self.doc.start_paragraph('DDR-MoreDetails') atype = str( alt_name.get_type() ) aname = alt_name.get_regular_name() - self.doc.write_text(_('%(name_kind)s: %(name)s%(endnotes)s') % { + self.doc.write_text_citation(_('%(name_kind)s: %(name)s%(endnotes)s') % { 'name_kind' : atype, 'name' : aname, 'endnotes' : self.endnotes(alt_name), @@ -628,7 +628,7 @@ class DetDescendantReport(Report): if date: self.doc.write_text( '%s, ' % date ) self.doc.write_text( text ) - self.doc.write_text( self.endnotes(addr) ) + self.doc.write_text_citation( self.endnotes(addr) ) self.doc.end_paragraph() if self.inc_attrs: @@ -646,7 +646,7 @@ class DetDescendantReport(Report): 'type' : attr.get_type(), 'value' : attr.get_value(), 'endnotes' : self.endnotes(attr) } - self.doc.write_text( text ) + self.doc.write_text_citation( text ) self.doc.end_paragraph() def calc_age(self,ind):