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 subprocess

Parameters: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 -f if self.from_format given. Third is -t if given and matching the self.file_out ending, otherwise changes self.file_out ending to .pdf and sets self.to_format to None. Last is the --verbose flag if self.verbose is True.

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 (if self.to_format is None)

-o self.file_out

self.file_in

Creates a subprocess using Popen, self.arguments is set as args of the subprocess. Sets the working directory (cwd) to self.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.template to htwberlin.tex, if self.template is not None. Adds -s, --data-dir=. to self.arguments. --data-dir is set to the current directory because the working directory of the subprocess will be set to self.path_to_files. Adds --template=self.template if self.to_format is None, so output will be pdf. Or adds --reference=self.template if self.to_format is docx and self.template ends in .docx

Returns: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.template to htwberlin.tex, if self.template is not None. Adds --bibliography=self.bib (if self.bib is not None) to self.arguments. Adds -s, --data-dir=. and --template=self.template to self.arguments. --data-dir is set to the current directory because the working directory of the subprocess will be set to self.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.template to htwberlin-beamer.tex, if self.template is not None. Adds -s, --data-dir=. to self.arguments. --data-dir is set to the current directory because the working directory of the subprocess will be set to self.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.template to htwberlin.tex, if self.template is not None. Adds -s, --data-dir=. to self.arguments. --data-dir is set to the current directory because the working directory of the subprocess will be set to self.path_to_files. Adds --template=self.template if self.to_format is None, so output will be pdf. Or adds --reference=self.template if self.to_format is odt and self.template ends in .odt

Returns:nothing

Indices and tables