From 6282fa7a9d5184b6bcfb6d2ac2a64c9a20e3615d Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 13 Nov 2002 13:36:23 +0000 Subject: [PATCH] Patches from ADL svn: r1187 --- src/docgen/LaTeXDoc.py | 28 ++++++++++++++++------------ src/plugins/WriteGedcom.py | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/docgen/LaTeXDoc.py b/src/docgen/LaTeXDoc.py index 0d12be42d..82a5fb4e7 100644 --- a/src/docgen/LaTeXDoc.py +++ b/src/docgen/LaTeXDoc.py @@ -80,6 +80,7 @@ # #------------------------------------------------------------------------ from TextDoc import * +from re import sub import ImgManip try: import Plugins @@ -116,7 +117,7 @@ class TexFont(TextDoc): #------------------------------------------------------------------------ # -# LaTeXDon +# LaTeXDoc # #------------------------------------------------------------------------ class LaTeXDoc(TextDoc): @@ -627,19 +628,11 @@ class LaTeXDoc(TextDoc): def write_text(self,text): """Write the text to the file""" if not self.in_listing: - # Quote unsafe characters. - text = string.replace(text,'\\','\\\\') - text = string.replace(text,'$','\\$') - text = string.replace(text,'&','\\&') - text = string.replace(text,'%','\\%') - text = string.replace(text,'#','\\#') - text = string.replace(text,'{','\\{') - text = string.replace(text,'}','\\}') - text = string.replace(text,'_','\\_') - text = string.replace(text,'^','\\verb+^+') - text = string.replace(text,'~','\\verb+~+') if text == '\n': text = '\\newline\n' + else: + # Quote unsafe characters. + text = sub('[\\$&%#{}_^~]',quote_fun,text) self.f.write(text) if text: self.last_char_written = text[-1] @@ -657,6 +650,17 @@ class LaTeXDoc(TextDoc): self.end_italic() self.write_text(") ") +def quote_fun(matchobj): + """Quote unsafe LaTeX characters""" + c = matchobj.group() + if c == '^': + return '\\verb+^+' + elif c == '~': + return '\\verb+~+' + else: + return '\\' + c + + #------------------------------------------------------------------------ # # Register the document generator with the system if in Gramps diff --git a/src/plugins/WriteGedcom.py b/src/plugins/WriteGedcom.py index 99396fe2a..52c2ced1f 100644 --- a/src/plugins/WriteGedcom.py +++ b/src/plugins/WriteGedcom.py @@ -674,7 +674,7 @@ class GedcomWriter: self.dump_event_stats(event) - if self.adopt == ADOPT_EVENT and ad == 0 and len(person.getParentList()) != 0: + if self.adopt == ADOPT_EVENT and ad == 0 and len(person.getParentList()) > 1: self.g.write('1 ADOP\n') fam = None for f in person.getParentList():