Fix pdf export , make it python3 compatible, Fix markmin2latex import

This commit is contained in:
jvanbraekel committed 2018-08-02 11:04:14 +02:00
1 parent 0d8dc294e9
commit 68284be7b0
3 files changed
+9 -10

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@ filename = '%s/%s.html' % (request.controller,request.function)
if os.path.exists(os.path.join(request.folder,'views',filename)): if os.path.exists(os.path.join(request.folder,'views',filename)):
html=response.render(filename) html=response.render(filename)
else: else:
html=BODY(BEAUTIFY(response._vars)).xml() html=BODY(BEAUTIFY(response._vars))
pass pass
=pdf_from_html(html) =pdf_from_html(html)
}} }}
+2 -2
View File
@@ -25,7 +25,7 @@ def wrapper(f):
def latex_from_html(html): def latex_from_html(html):
markmin = TAG(html).element('body').flatten(markmin_serializer) markmin = TAG(html).element('body').flatten(markmin_serializer)
return XML(markmin2latex(markmin)) return markmin2latex(markmin)
def pdflatex_from_html(html): def pdflatex_from_html(html):
@@ -39,7 +39,7 @@ def pdflatex_from_html(html):
H1('warnings'), H1('warnings'),
UL(*warnings))).xml()) UL(*warnings))).xml())
else: else:
return XML(out) return out
def pyfpdf_from_html(html): def pyfpdf_from_html(html):
+6 -7
View File
@@ -58,7 +58,7 @@ def latex2pdf(latex, pdflatex='pdflatex', passes=3):
# setup the envoriment # setup the envoriment
tmpdir = mkdtemp() tmpdir = mkdtemp()
texfile = open(tmpdir + '/test.tex', 'wb') texfile = open(tmpdir + '/test.tex', 'wt',encoding="utf-8")
texfile.write(latex) texfile.write(latex)
texfile.seek(0) texfile.seek(0)
texfile.close() texfile.close()
@@ -90,15 +90,14 @@ def latex2pdf(latex, pdflatex='pdflatex', passes=3):
os.unlink(logname) os.unlink(logname)
pdffile = texfile.rsplit('.', 1)[0] + '.pdf' pdffile = texfile.rsplit('.', 1)[0] + '.pdf'
data = None
if os.path.isfile(pdffile): if os.path.isfile(pdffile):
fpdf = open(pdffile, 'rb') with open(pdffile,'rb') as fpdf :
try:
data = fpdf.read() data = fpdf.read()
finally:
fpdf.close()
else:
data = None
removeall(tmpdir) removeall(tmpdir)
return data, warnings, errors return data, warnings, errors