pydocmaker.backend.pandoc_api
Attributes
Classes
Functions
|
|
|
Convert text between different formats using Pandoc. |
|
Set whether or not pandoc is allowed to be used as a valid conversion option |
Get whether or not pandoc is allowed to be used as a valid conversion option |
|
|
Convert a file using pandoc. |
|
Convert a file using pandoc. |
|
|
|
Module Contents
- pydocmaker.backend.pandoc_api.log
- pydocmaker.backend.pandoc_api.allow_pandoc = True
- pydocmaker.backend.pandoc_api._is_pandoc_installed = None
- pydocmaker.backend.pandoc_api.test_is_pandoc_installed()
- pydocmaker.backend.pandoc_api.can_run_pandoc(force_retest=False)
- pydocmaker.backend.pandoc_api.pandoc_convert(input_string, input_format, output_format, is_binary=False, *args)
Convert text between different formats using Pandoc.
This function wraps the pandoc command-line tool to convert text from one format to another. It handles both text and binary conversions, with proper encoding and error handling.
- Parameters:
input_string (str) – The text to be converted
input_format (str) – The source format (e.g., ‘markdown’, ‘rst’)
output_format (str) – The target format (e.g., ‘html’, ‘latex’)
is_binary (bool) – If True, treat input/output as binary data
*args – Additional arguments to pass to pandoc
- Returns:
- The converted text. If is_binary is True, returns bytes;
otherwise returns a UTF-8 decoded string
- Return type:
str or bytes
- Raises:
RuntimeError – If pandoc returns an error message
Note
If input_format equals output_format, the original input_string is returned without invoking pandoc, as it would be redundant.
- pydocmaker.backend.pandoc_api.pandoc_set_allowed(is_allowed)
Set whether or not pandoc is allowed to be used as a valid conversion option
- pydocmaker.backend.pandoc_api.pandoc_get_allowed()
Get whether or not pandoc is allowed to be used as a valid conversion option
- pydocmaker.backend.pandoc_api.config_pandoc_allowed_set
- pydocmaker.backend.pandoc_api.config_pandoc_allowed_get
- pydocmaker.backend.pandoc_api.pandoc_merge_files(inp_files, out_file)
Convert a file using pandoc.
Parameters: inp_files (List[str]): The path to the input file. out_file (str or Path): The path to the output file or the desired output format.
Returns: subprocess.CompletedProcess: The result of the pandoc conversion command.
Raises: AssertionError: If the input file does not exist or if no output file or format is provided.
- pydocmaker.backend.pandoc_api.pandoc_convert_file(inp_file, out_file_or_format)
Convert a file using pandoc.
Parameters: inp_file (str): The path to the input file. out_file_or_format (str or Path): The path to the output file or the desired output format.
If it’s a string starting with a dot, it’s considered as a file extension and the output file will be the input file with the new extension.
Returns: subprocess.CompletedProcess: The result of the pandoc conversion command.
Raises: AssertionError: If the input file does not exist or if no output file or format is provided.
- pydocmaker.backend.pandoc_api.convert(output_format, doc: List[dict], with_attachments=True, files_to_upload=None)
- pydocmaker.backend.pandoc_api.pandoc_to_pdf(input_file, output_pdf)
- class pydocmaker.backend.pandoc_api.PandocFormatter(output_format, *pandoc_args)
- output_format
- pandoc_args = ()
- conv(string, input_format, *args)
- handle_error(err, el)
- digest_markdown(children='', **kwargs) str
- digest_image(children='', width=None, caption='', imageblob=None, **kwargs)
- digest_verbatim(children='', **kwargs) str
- digest_iterator(el) str
- digest_str(el)
- digest_text(children: str, **kwargs)
- digest_line(children: str, **kwargs)
- digest_latex(children: str, **kwargs)
- digest(el)
- format(doc: list) str