autowriterllm package

Submodules

autowriterllm.ai_content_generator module

autowriterllm.markdown_to_pdf_converter module

class autowriterllm.markdown_to_pdf_converter.ConverterConfig(max_workers: int = 4, supported_encodings: ~typing.List[str] = <factory>, temp_filename: str = 'combined_temp.md', pandoc_options: ~typing.Dict[str, ~typing.Any] = <factory>)[source]

Bases: object

Configuration settings for the PDF converter.

Variables:
  • max_workers (int) – Maximum number of worker threads for parallel processing

  • supported_encodings (List[str]) – List of encodings to try when reading files

  • temp_filename (str) – Name of temporary combined markdown file

  • pandoc_options (Dict[str, Any]) – Additional pandoc conversion options

max_workers: int = 4
pandoc_options: Dict[str, Any]
supported_encodings: List[str]
temp_filename: str = 'combined_temp.md'
class autowriterllm.markdown_to_pdf_converter.ConverterGUI[source]

Bases: object

GUI interface for the markdown to PDF converter.

__init__()[source]

Initialize the GUI.

_create_widgets()[source]

Create and arrange GUI widgets.

_select_css()[source]

Handle CSS file selection.

_select_input_dir()[source]

Handle input directory selection.

_select_output()[source]

Handle output PDF file selection.

_select_toc()[source]

Handle table of contents file selection.

_start_conversion()[source]

Start the PDF conversion process.

_validate_inputs()[source]

Validate inputs and enable/disable convert button.

run()[source]

Start the GUI main loop.

update_log(message: str)[source]

Update the log display.

class autowriterllm.markdown_to_pdf_converter.MarkdownToPDFConverter(toc_file: Path, output_dir: Path, css_file: Path | None = None, config: ConverterConfig | None = None)[source]

Bases: object

Converts markdown files to a single PDF document using pandoc.

__init__(toc_file: Path, output_dir: Path, css_file: Path | None = None, config: ConverterConfig | None = None)[source]

Initialize the converter.

Parameters:
  • toc_file – Path to table of contents markdown file

  • output_dir – Directory containing markdown files

  • css_file – Optional path to custom CSS file

  • config – Optional configuration settings

Raises:

ValueError – If toc_file or output_dir don’t exist

_check_dependencies() None[source]

Check if required dependencies are installed.

_cleanup()[source]

Clean up temporary files and resources.

_create_combined_markdown(temp_md: Path, contents: List[str])[source]

Create a combined markdown file from processed markdown content.

_parse_toc() List[str][source]

Parse table of contents to get ordered list of markdown files.

Returns:

Ordered list of markdown filenames

Return type:

List[str]

Example ordering:

chapter-1.md chapter-1-1.md chapter-1-1-1.md chapter-1-2.md chapter-2.md chapter-2-1.md

_process_markdown_files(files: List[str]) List[str][source]

Process markdown files in parallel.

Parameters:

files – List of markdown filenames to process

Returns:

Processed markdown content

Return type:

List[str]

Raises:

RuntimeError – If any file processing fails

_read_file_with_fallback_encoding(file_path: Path) str[source]

Read file content with fallback encodings.

_run_pandoc_conversion(temp_md: Path, output_file: Path)[source]

Run pandoc conversion using the combined markdown file.

convert_to_pdf(output_file: Path) None[source]

Convert markdown files to PDF using pandoc.

Parameters:

output_file – Path where the output PDF will be saved

Raises:
autowriterllm.markdown_to_pdf_converter.main()[source]

Main entry point.

Module contents

AutoWriterLLM - Automatic book writing tool using LLMs.