Welcome to pandocwrapper's documentation!¶
pandocwrapper¶
-
class
pandocwrapper.BaseConverter(file_in, file_out=None, from_format=None, to_format=None, path_to_files='.', verbose=False)¶ Base Converter
Class to convert from and to different formats, default is to convert to PDF.
-
add_arguments(*to_add)¶ Adds argument to list of arguments(
self.arguments), that will be executed as a command in a subprocessParameters: to_add (str or list of str) -- argument(s) to add to the argument list Returns: nothing
-
construct_command()¶ Constructs the base command, based on the class attributes.
Always starts with
pandoc. Second is-fifself.from_formatgiven. Third is-tif given and matching theself.file_outending, otherwise changesself.file_outending to .pdf and setsself.to_formattoNone. Last is the--verboseflag ifself.verboseisTrue.Returns: nothing
-
convert()¶ Converts the input file by sending the pandoc command to a subprocess.
- First adds missing, but common arguments to the arguments list:
--pdf-engine(ifself.to_formatisNone)-o self.file_outself.file_in
Creates a subprocess using Popen,
self.argumentsis set asargsof the subprocess. Sets the working directory (cwd) toself.path_to_files.Prints stdout and error (if happened) of subprocess to console.
Returns: nothing
-
-
class
pandocwrapper.DocxConverter(file_in, file_out=None, template=None, from_format='docx', to_format=None, path_to_files='.', verbose=False)¶ Docx Converter
Converts from docx to different formats, default is to convert to PDF.
-
construct_command()¶ Calls
BaseConverter.construct_command()first.Sets
self.templateto htwberlin.tex, ifself.templateis not None. Adds-s,--data-dir=.toself.arguments.--data-diris set to the current directory because the working directory of the subprocess will be set toself.path_to_files. Adds--template=self.templateifself.to_formatis None, so output will be pdf. Or adds--reference=self.templateifself.to_formatis docx andself.templateends in .docxReturns: nothing
-
-
class
pandocwrapper.LatexConverter(file_in, file_out=None, bib=None, template=None, resources_path=None, from_format='latex', to_format=None, path_to_files='.', verbose=False)¶ Latex Converter
Converts from latex to different formats, default is to convert to PDF.
-
construct_command()¶ Calls
BaseConverter.construct_command()first.Sets
self.templateto htwberlin.tex, ifself.templateis not None. Adds--bibliography=self.bib(ifself.bibis notNone) toself.arguments. Adds-s,--data-dir=.and--template=self.templatetoself.arguments.--data-diris set to the current directory because the working directory of the subprocess will be set toself.path_to_files.Returns: nothing
-
-
class
pandocwrapper.MdConverter(file_in, file_out=None, template=None, from_format='markdown', path_to_files='.', verbose=False, toc=False)¶ Markdown Converter
Converts from markdown to PDF using beamer
-
construct_command()¶ Calls
BaseConverter.construct_command()first.Sets
self.templateto htwberlin-beamer.tex, ifself.templateis not None. Adds-s,--data-dir=.toself.arguments.--data-diris set to the current directory because the working directory of the subprocess will be set toself.path_to_files. Adds -t beamer!Returns: nothing
-
-
class
pandocwrapper.OdtConverter(file_in, file_out=None, template=None, from_format='odt', to_format=None, path_to_files='.', verbose=False)¶ Odt Converter
Converts from odt to different formats, default is to convert to PDF.
-
construct_command()¶ Calls
BaseConverter.construct_command()first.Sets
self.templateto htwberlin.tex, ifself.templateis not None. Adds-s,--data-dir=.toself.arguments.--data-diris set to the current directory because the working directory of the subprocess will be set toself.path_to_files. Adds--template=self.templateifself.to_formatis None, so output will be pdf. Or adds--reference=self.templateifself.to_formatis odt andself.templateends in .odtReturns: nothing
-