diff --git a/src/plugins/docgen/AsciiDoc.py b/src/plugins/docgen/AsciiDoc.py index 38e51818d..4e83468b5 100644 --- a/src/plugins/docgen/AsciiDoc.py +++ b/src/plugins/docgen/AsciiDoc.py @@ -4,6 +4,7 @@ # Copyright (C) 2000-2006 Donald N. Allingham # Copyright (C) 2007-2009 Brian G. Matherly # Copyright (C) 2009 Benny Malengier +# Copyright (C) 2010 Peter Landgren # # 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 @@ -123,6 +124,10 @@ def reformat_para(para='',left=0,right=72,just=LEFT,right_pad=0,first=0): #------------------------------------------------------------------------ class AsciiDoc(BaseDoc,TextDoc): + def __init__(self, styles, type): + BaseDoc.__init__(self, styles, type) + self.__note_format = False + #-------------------------------------------------------------------- # # Opens the file, resets the text buffer. @@ -239,8 +244,13 @@ class AsciiDoc(BaseDoc,TextDoc): # line indent, as specified by style. this_text = reformat_para(self.text,regular_indent,right,fmt, right_pad,first_indent) - - this_text += '\n' + the_pad + '\n' + if self.__note_format: + # don't add an extra LF before the_pad if preformatted notes. + if this_text != '\n': + # don't add LF if there is this_text is a LF + this_text += the_pad + '\n' + else: + this_text += '\n' + the_pad + '\n' if self.in_cell: self.cellpars[self.cellnum] = self.cellpars[self.cellnum] + \ @@ -343,12 +353,20 @@ class AsciiDoc(BaseDoc,TextDoc): else: self.f.write(this_text) - def write_note(self,text,format,style_name): + def write_styled_note(self,styledtext,format,style_name): + text = str(styledtext) if format == 1: + # Preformatted note + self.__note_format = True for line in text.split('\n'): self.start_paragraph(style_name) self.write_text(line) self.end_paragraph() + # Add an extra LF after all lines in each preformatted note + self.__note_format = False + self.start_paragraph(style_name) + self.write_text('\n') + self.end_paragraph() elif format == 0: for line in text.split('\n\n'): self.start_paragraph(style_name) @@ -357,6 +375,21 @@ class AsciiDoc(BaseDoc,TextDoc): self.write_text(line) self.end_paragraph() + def write_endnotes_ref(self, text, style_name): + """ + Overwrite base method for lines of endnotes references + """ + self.__note_format = True + for line in text.split('\n'): + self.start_paragraph(style_name) + self.write_text(line) + self.end_paragraph() + # Add an extra LF after all lines in each preformatted note + self.__note_format = False + self.start_paragraph(style_name) + self.write_text('\n') + self.end_paragraph() + #-------------------------------------------------------------------- # # Writes text. diff --git a/src/plugins/docgen/HtmlDoc.py b/src/plugins/docgen/HtmlDoc.py index 19d165658..ac342a4d0 100644 --- a/src/plugins/docgen/HtmlDoc.py +++ b/src/plugins/docgen/HtmlDoc.py @@ -4,6 +4,7 @@ # Copyright (C) 2000-2006 Donald N. Allingham # Copyright (C) 2007-2009 Brian G. Matherly # Copyright (C) 2009 Benny Malengier +# Copyright (C) 2010 Peter Landgren # # 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 @@ -450,28 +451,19 @@ class HtmlDoc(BaseDoc, TextDoc): """ self.__reduce_list() - def write_note(self, text, format, style_name): + def write_endnotes_ref(self, text, style_name): """ - Overwrite base method + Overwrite base method for lines of endnotes references """ self.htmllist += [Html('div', id='grampsstylednote')] - if format == 1: - #preformatted, retain whitespace. - # User should use write_styled_note for correct behavior, in this - # more basic method we convert all to a monospace character + for line in text.split('\n'): + # more basic method we convert all to a monospace character self.htmllist += [Html('pre', class_=style_name, - style = 'font-family: courier, monospace', - indent=None, inline=True)] - self.write_text(text) + style = 'font-family: courier, monospace', + indent=None, inline=True)] + self.write_text(line) #end pre element self.__reduce_list() - elif format == 0: - for line in text.split('\n\n'): - self.start_paragraph(style_name) - self.write_text(line) - self.end_paragraph() - else: - raise NotImplementedError #end div element self.__reduce_list() diff --git a/src/plugins/docgen/LaTeXDoc.py b/src/plugins/docgen/LaTeXDoc.py index 5df256317..48d139787 100644 --- a/src/plugins/docgen/LaTeXDoc.py +++ b/src/plugins/docgen/LaTeXDoc.py @@ -7,6 +7,7 @@ # 2002-2003 Donald A. Peterson # 2003 Alex Roitman # 2009 Benny Malengier +# 2010 Peter Landgren # # 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 @@ -647,12 +648,17 @@ class LaTeXDoc(BaseDoc, TextDoc): #preformatted finished, go back to normal escape function self._backend.setescape(False) - def write_note(self,text,format,style_name): - """Write the note's text to the file, respecting the format""" - self.start_paragraph(style_name) - if format == 1: - self._backend.write('\\begin{verbatim}') - self.write_text(text) - if format == 1: - self._backend.write('\\end{verbatim}') - self.end_paragraph() + def write_endnotes_ref(self, text, style_name): + """ + Overwrite base method for lines of endnotes references + """ + self._backend.write("\\begin{minipage}{{0.8\\linewidth}}\n") + for line in text.split('\n'): + self.start_paragraph(style_name) + if format == 0: + self._backend.write('\\begin{verbatim}') + self.write_text(line) + if format == 0: + self._backend.write('\\end{verbatim}') + self.end_paragraph() + self._backend.write("\n\\vspace*{0.5cm} \n\end{minipage}\n\n") diff --git a/src/plugins/docgen/ODFDoc.py b/src/plugins/docgen/ODFDoc.py index 3677776e3..c346d4fbf 100644 --- a/src/plugins/docgen/ODFDoc.py +++ b/src/plugins/docgen/ODFDoc.py @@ -4,6 +4,7 @@ # Copyright (C) 2000-2006 Donald N. Allingham # Copyright (C) 2005-2009 Serge Noiraud # Copyright (C) 2007-2009 Brian G. Matherly +# Copyright (C) 2010 Peter Landgren # # 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 @@ -1185,27 +1186,21 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): self.cntnt.write('\n') self.new_cell = 1 - def write_note(self, text, format, style_name): + def write_endnotes_ref(self, text, style_name): """ - write a note + Overwrite base method for lines of endnotes references """ - if format == 1: - text = escape(text, _esc_map) + for line in text.split('\n'): + text = escape(line, _esc_map) # Replace multiple spaces: have to go from the largest number down for n in range(text.count(' '), 1, -1): text = text.replace(' '*n, ' ' % (n-1) ) self.start_paragraph(style_name) - self.cntnt.write('') +# self.cntnt.write('') + self.cntnt.write('') self.cntnt.write(text) self.cntnt.write('') self.end_paragraph() - elif format == 0: - for line in text.split('\n\n'): - self.start_paragraph(style_name) - line = line.replace('\n', ' ') - line = ' '.join(line.split()) - self.write_text(line) - self.end_paragraph() def write_styled_note(self, styledtext, format, style_name): """ diff --git a/src/plugins/docgen/RTFDoc.py b/src/plugins/docgen/RTFDoc.py index 54ddcf808..5d1abd628 100644 --- a/src/plugins/docgen/RTFDoc.py +++ b/src/plugins/docgen/RTFDoc.py @@ -4,6 +4,7 @@ # Copyright (C) 2000-2006 Donald N. Allingham # Copyright (C) 2007-2009 Brian G. Matherly # Copyright (C) 2009 Gary Burton +# Copyright (C) 2010 Peter Landgren # # 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 @@ -395,11 +396,16 @@ class RTFDoc(BaseDoc,TextDoc): index = index+1 self.f.write('}}\\par\n') - def write_note(self,text,format,style_name): + def write_styled_note(self,styledtext,format,style_name): + text = str(styledtext) if format == 1: + # Preformatted note for line in text.split('\n'): self.start_paragraph(style_name) self.write_text(line) + if self.in_table: + # Add LF when in table as in indiv_complete report + self.write_text('\n') self.end_paragraph() elif format == 0: for line in text.split('\n\n'): @@ -408,6 +414,25 @@ class RTFDoc(BaseDoc,TextDoc): line = ' '.join(line.split()) self.write_text(line) self.end_paragraph() + self.start_paragraph(style_name) + self.write_text('\n') + self.end_paragraph() + + def write_endnotes_ref(self,text,style_name): + """ + Overwrite base method for lines of endnotes references + """ + for line in text.split('\n'): + self.start_paragraph(style_name) + self.write_text(line) + if self.in_table: + # Add LF when in table as in indiv_complete report + self.write_text('\n') + self.end_paragraph() + # Write NL after all ref lines for each source + self.start_paragraph(style_name) + self.write_text('\n') + self.end_paragraph() #-------------------------------------------------------------------- #