all2md.cli.packaging

Output packaging utilities for all2md CLI.

This module provides utilities for creating zip packages of converted documents directly from memory without intermediate disk I/O.

all2md.cli.packaging.create_package_from_conversions(input_items: List[CLIInputItem], zip_path: Path, target_format: str = 'markdown', options: Dict[str, Any] | None = None, transforms: list | None = None, source_format: str = 'auto', progress_callback: Any | None = None, option_resolver: Callable[[CLIInputItem], Dict[str, Any]] | None = None) Path

Create zip package by converting files directly to memory without disk I/O.

This function converts input files on-the-fly and writes them directly to a zip archive using BytesIO buffers, eliminating the need for intermediate disk writes. Files are processed one at a time to minimize memory usage.

Parameters:
  • input_items (List[CLIInputItem]) – List of input items to convert and package

  • zip_path (Path) – Path for the output zip file

  • target_format (str, default="markdown") – Target output format (e.g., “markdown”, “html”, “pdf”)

  • options (Dict[str, Any], optional) – Conversion options to pass to convert()

  • transforms (list, optional) – AST transforms to apply during conversion

  • source_format (str, default="auto") – Source format (auto-detect if “auto”)

  • progress_callback (ProgressCallback, optional) – Optional callback for progress updates

  • option_resolver (Callable[[CLIInputItem], dict], optional) – Projects options onto the kwargs one item’s formats actually accept, called once per item. The CLI’s options dict is namespaced (pdf.pages, view.dark) and has to be flattened against the format that will handle each file; without this every key is forwarded verbatim and the API reports the unusable ones as the caller’s typos (#303). When omitted, options is passed through unchanged.

Returns:

Path to the created zip file

Return type:

Path

Notes

This function automatically uses base64 embedding for attachments to keep everything in memory. Files are processed incrementally to minimize RAM usage.

Examples

Create a zip of markdown files:

>>> create_package_from_conversions(
...     [Path("doc1.pdf"), Path("doc2.pdf")],
...     Path("output.zip"),
...     target_format="markdown"
... )