Merge pull request #79 from vkbo/latex_bugs

LaTeX bug fixes
This commit is contained in:
Veronica K. Berglyd Olsen
2019-10-28 10:33:53 +01:00
committed by GitHub
2 changed files with 8 additions and 8 deletions
+5 -6
View File
@@ -23,9 +23,7 @@ class LaTeXFile(TextFile):
def __init__(self, theProject, theParent): def __init__(self, theProject, theParent):
TextFile.__init__(self, theProject, theParent) TextFile.__init__(self, theProject, theParent)
self.theConv = ToLaTeX(self.theProject, self.theParent) self.theConv = ToLaTeX(self.theProject, self.theParent)
return return
## ##
@@ -36,9 +34,10 @@ class LaTeXFile(TextFile):
try: try:
self.outFile = open(filePath,mode="wt+") self.outFile = open(filePath,mode="wt+")
self.outFile.write(r"\documentclass[12pt]{report}\n") self.outFile.write("\\documentclass[12pt]{report}\n")
self.outFile.write(r"\usepackage[utf8]{inputenc}\n") self.outFile.write("\\usepackage[utf8]{inputenc}\n")
self.outFile.write(r"\begin{document}\n") self.outFile.write("\n")
self.outFile.write("\\begin{document}\n")
except Exception as e: except Exception as e:
self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR) self.makeAlert(["Failed to open file.",str(e)], nwAlert.ERROR)
return False return False
@@ -48,7 +47,7 @@ class LaTeXFile(TextFile):
def _doCloseFile(self): def _doCloseFile(self):
if self.outFile is not None: if self.outFile is not None:
self.outFile.write(r"\end{document}\n") self.outFile.write("\\end{document}\n")
self.outFile.close() self.outFile.close()
return True return True
+3 -2
View File
@@ -110,12 +110,13 @@ class ToLaTeX(Tokenizer):
tText = tWrap.fill(tText) tText = tWrap.fill(tText)
# Then the text can receive final formatting before we append it to the results. # Then the text can receive final formatting before we append it to the results.
# We also store text lines in a buffer and merge them only when we find an empty line, # We also store text lines in a buffer and merge them only when we find an empty line
# indicating a new paragraph. # indicating a new paragraph.
if tType == self.T_EMPTY: if tType == self.T_EMPTY:
if len(thisPar) > 0: if len(thisPar) > 0:
self.theResult += begText self.theResult += begText
self.theResult += "%s\n" % tWrap.fill(" ".join(thisPar)) for tTemp in thisPar:
self.theResult += "%s\n" % tTemp
self.theResult += endText self.theResult += endText
thisPar = [] thisPar = []