Added UNICODE support and '&' replacement

svn: r1866
This commit is contained in:
Donald A. Peterson 2003-07-11 15:30:44 +00:00
parent 132e068414
commit 271f82225c

View File

@ -108,10 +108,10 @@ class LaTeXDoc(TextDoc.TextDoc):
options = options + ",letterpaper" options = options + ",letterpaper"
# Use the article template, T1 font encodings, and specify # Use the article template, T1 font encodings, and specify
# that we should use Latin1 character encodings. # that we should use Latin1 and unicode character encodings.
self.f.write('\\documentclass[%s]{article}\n' % options) self.f.write('\\documentclass[%s]{article}\n' % options)
self.f.write('\\usepackage[T1]{fontenc}\n') self.f.write('\\usepackage[T1]{fontenc}\n')
self.f.write('\\usepackage[latin1]{inputenc}\n') self.f.write('\\usepackage[latin1,utf8]{inputenc}\n')
# add packages (should be standard on a default installation) # add packages (should be standard on a default installation)
# for finer output control. Put comments in file for user to read # for finer output control. Put comments in file for user to read
self.f.write('\\usepackage{graphicx} % Extended graphics support\n') self.f.write('\\usepackage{graphicx} % Extended graphics support\n')
@ -232,7 +232,7 @@ class LaTeXDoc(TextDoc.TextDoc):
def start_paragraph(self,style_name,leader=None): def start_paragraph(self,style_name,leader=None):
"""Paragraphs handling - A Gramps paragraph is any """Paragraphs handling - A Gramps paragraph is any
single body of text, from a single word, to several sentences. single body of text from a single word to several sentences.
We assume a linebreak at the end of each paragraph.""" We assume a linebreak at the end of each paragraph."""
style = self.style_list[style_name] style = self.style_list[style_name]
@ -387,6 +387,7 @@ class LaTeXDoc(TextDoc.TextDoc):
if text == '\n': if text == '\n':
text = '\\newline\n' text = '\\newline\n'
text = string.replace(text,'#','\#') text = string.replace(text,'#','\#')
text = string.replace(text,'&','\&')
text = text.replace('<super>','\\textsuperscript{') text = text.replace('<super>','\\textsuperscript{')
text = text.replace('</super>','}') text = text.replace('</super>','}')
self.f.write(text) self.f.write(text)
@ -405,3 +406,12 @@ Plugins.register_text_doc(
style=0, style=0,
ext=".tex" ext=".tex"
) )
Plugins.register_book_doc(
name=_("LaTeX"),
classref=LaTeXDoc,
table=1,
paper=1,
style=0,
ext=".tex"
)