Fixes Pandoc PDF output error with unicode characters #117

This commit is contained in:
Olivier Keshavjee 2017-06-15 14:37:55 +02:00
parent 230b034232
commit dfed1e7ec9

View file

@ -19,7 +19,7 @@ class PDF(abstractOutput):
name = "PDF"
description = qApp.translate("Export", "Needs latex to be installed.")
InvalidBecause = qApp.translate("Export", """a valid latex installation. See pandoc recommendations on:
<a href="http://pandoc.org/installing.html">http://pandoc.org/installing.html</a>""")
<a href="http://pandoc.org/installing.html">http://pandoc.org/installing.html</a>. If you want unicode support, you need xelatex.""")
icon = "application-pdf"
exportVarName = "lastPandocPDF"
@ -31,13 +31,15 @@ class PDF(abstractOutput):
}
def isValid(self):
path = shutil.which("pdflatex")
path = shutil.which("pdflatex") or shutil.which("xelatex")
return path is not None
def output(self, settingsWidget, outputfile=None):
args = settingsWidget.runnableSettings()
args.remove("--to=pdf")
args.append("--to=latex")
if shutil.which("xelatex"):
args.append("--latex-engine=xelatex")
src = self.src(settingsWidget)
return self.exporter.convert(src, args, outputfile)
@ -50,4 +52,4 @@ class PDF(abstractOutput):
settingsWidget.writeSettings()
content = self.output(settingsWidget, outputfile=filename)
previewWidget.loadPDF(filename)
previewWidget.loadPDF(filename)