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