Patches from ADL

svn: r1187
This commit is contained in:
Don Allingham 2002-11-13 13:36:23 +00:00
parent 302ebfcee9
commit 6282fa7a9d
2 changed files with 17 additions and 13 deletions

View File

@ -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

View File

@ -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():