Change paper size for odt and docx files

github/fork/sternenseemann/patch-1
Thomas Lavend'Homme 2019-12-14 21:26:50 -05:00
parent bf73910483
commit 0fce1bae77
No known key found for this signature in database
GPG Key ID: CCA8234E45728B5C
2 changed files with 20 additions and 3 deletions

View File

@ -221,7 +221,7 @@ class Export:
if self.builder.get_object("smart").get_active():
to += "+smart"
args.extend(self.get_advanced_arguments())
args.extend(self.get_advanced_arguments(to, ext))
else:
args = [
@ -244,11 +244,12 @@ class Export:
args.append("--lua-filter=%s" % helpers.get_script_path('relative_to_absolute.lua'))
args.append("--lua-filter=%s" % helpers.get_script_path('task-list.lua'))
helpers.pandoc_convert(
text, to=to, args=args,
outputfile="%s/%s.%s" % (output_dir, basename, ext))
def get_advanced_arguments(self):
def get_advanced_arguments(self, to_fmt, ext_fmt):
"""Retrieve a list of the selected advanced arguments
For most of the advanced option checkboxes, returns a list
@ -256,6 +257,8 @@ class Export:
Arguments:
basename {str} -- the name of the file
to_fmt {str} -- the format of the export
ext_fmt {str} -- the extension of the export
Returns:
list of {str} -- related pandoc flags
@ -265,10 +268,15 @@ class Export:
conditions = [
{
"condition": True,
"condition": to_fmt == "pdf",
"yes": "--variable=papersize:" + self.get_paper_size(),
"no": None
},
{
"condition": self.get_paper_size() == "a4" and (to_fmt == "odt" or to_fmt == "docx"),
"yes": "--reference-doc " + helpers.get_reference_files_path('reference-a4.'+to_fmt) + to_fmt,
"no": None
},
{
"condition": self.builder.get_object("toc").get_active(),
"yes": "--toc",

View File

@ -85,6 +85,15 @@ def get_script_path(script_file_name):
return script_path
def get_reference_files_path(reference_file_name):
"""Return the full path of a given filename under the reference_files dir
"""
refs_path = get_data_file('reference_files', '%s' % (reference_file_name,))
if not os.path.exists(refs_path):
refs_path = None
return refs_path
class NullHandler(logging.Handler):
def emit(self, record):
pass