pydocmaker.backend.pandoc_api ============================= .. py:module:: pydocmaker.backend.pandoc_api Attributes ---------- .. autoapisummary:: pydocmaker.backend.pandoc_api.log pydocmaker.backend.pandoc_api.allow_pandoc pydocmaker.backend.pandoc_api._is_pandoc_installed pydocmaker.backend.pandoc_api.config_pandoc_allowed_set pydocmaker.backend.pandoc_api.config_pandoc_allowed_get Classes ------- .. autoapisummary:: pydocmaker.backend.pandoc_api.PandocFormatter Functions --------- .. autoapisummary:: pydocmaker.backend.pandoc_api.test_is_pandoc_installed pydocmaker.backend.pandoc_api.can_run_pandoc pydocmaker.backend.pandoc_api.pandoc_convert pydocmaker.backend.pandoc_api.pandoc_set_allowed pydocmaker.backend.pandoc_api.pandoc_get_allowed pydocmaker.backend.pandoc_api.pandoc_merge_files pydocmaker.backend.pandoc_api.pandoc_convert_file pydocmaker.backend.pandoc_api.convert pydocmaker.backend.pandoc_api.pandoc_to_pdf Module Contents --------------- .. py:data:: log .. py:data:: allow_pandoc :value: True .. py:data:: _is_pandoc_installed :value: None .. py:function:: test_is_pandoc_installed() .. py:function:: can_run_pandoc(force_retest=False) .. py:function:: 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. :param input_string: The text to be converted :type input_string: str :param input_format: The source format (e.g., 'markdown', 'rst') :type input_format: str :param output_format: The target format (e.g., 'html', 'latex') :type output_format: str :param is_binary: If True, treat input/output as binary data :type is_binary: bool :param \*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 :rtype: 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. .. py:function:: pandoc_set_allowed(is_allowed) Set whether or not pandoc is allowed to be used as a valid conversion option .. py:function:: pandoc_get_allowed() Get whether or not pandoc is allowed to be used as a valid conversion option .. py:data:: config_pandoc_allowed_set .. py:data:: config_pandoc_allowed_get .. py:function:: 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. .. py:function:: 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. .. py:function:: convert(output_format, doc: List[dict], with_attachments=True, files_to_upload=None) .. py:function:: pandoc_to_pdf(input_file, output_pdf) .. py:class:: PandocFormatter(output_format, *pandoc_args) .. py:attribute:: output_format .. py:attribute:: pandoc_args :value: () .. py:method:: conv(string, input_format, *args) .. py:method:: handle_error(err, el) .. py:method:: digest_markdown(children='', **kwargs) -> str .. py:method:: digest_image(children='', width=None, caption='', imageblob=None, **kwargs) .. py:method:: digest_verbatim(children='', **kwargs) -> str .. py:method:: digest_iterator(el) -> str .. py:method:: digest_str(el) .. py:method:: digest_text(children: str, **kwargs) .. py:method:: digest_line(children: str, **kwargs) .. py:method:: digest_latex(children: str, **kwargs) .. py:method:: digest(el) .. py:method:: format(doc: list) -> str