diff --git a/gramps/src/docgen/LaTeXDoc.py b/gramps/src/docgen/LaTeXDoc.py index 0d12be42d..82a5fb4e7 100644 --- a/gramps/src/docgen/LaTeXDoc.py +++ b/gramps/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/gramps/src/plugins/WriteGedcom.py b/gramps/src/plugins/WriteGedcom.py index 99396fe2a..52c2ced1f 100644 --- a/gramps/src/plugins/WriteGedcom.py +++ b/gramps/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():