all2md.options.epub

Configuration options for EPUB parsing and rendering.

This module defines options for EPUB e-book format conversion.

class all2md.options.epub.EpubRendererOptions

Bases: BaseRendererOptions

Configuration options for rendering AST to EPUB format.

This dataclass contains settings specific to EPUB generation from AST, including chapter splitting strategies, metadata, and EPUB structure.

Parameters:
  • chapter_split_mode ({"separator", "heading", "auto"}, default "auto") – How to split the AST into chapters: - “separator”: Split on ThematicBreak nodes (mirrors parser behavior) - “heading”: Split on specific heading level - “auto”: Try separator first, fallback to heading-based splitting

  • chapter_split_heading_level (int, default 1) – Heading level to use for chapter splits when using heading mode. Level 1 (H1) typically represents chapter boundaries.

  • title (str or None, default None) – EPUB book title. If None, extracted from document metadata.

  • author (str or None, default None) – EPUB book author. If None, extracted from document metadata.

  • language (str, default "en") – EPUB book language code (ISO 639-1).

  • identifier (str or None, default None) – Unique identifier (ISBN, UUID, etc.). Auto-generated if None.

  • chapter_title_template (str, default "Chapter {num}") – Template for auto-generated chapter titles. Supports {num} placeholder.

  • use_heading_as_chapter_title (bool, default True) – Use first heading in chapter as chapter title in NCX/navigation.

  • generate_toc (bool, default True) – Generate table of contents (NCX and nav.xhtml files).

  • include_cover (bool, default False) – Include cover image in EPUB package.

  • cover_image_path (str or None, default None) – Path to cover image file. Only used if include_cover=True.

  • network (NetworkFetchOptions, default NetworkFetchOptions()) – Network security options for fetching remote images. By default, remote image fetching is disabled (allow_remote_fetch=False). Set network.allow_remote_fetch=True to enable secure remote image fetching.

chapter_split_mode: Literal['separator', 'heading', 'auto'] = 'auto'
chapter_split_heading_level: int = 1
title: str | None = None
author: str | None = None
language: str = 'en'
identifier: str | None = None
chapter_title_template: str = 'Chapter {num}'
use_heading_as_chapter_title: bool = True
generate_toc: bool = True
include_cover: bool = False
cover_image_path: str | None = None
network: NetworkFetchOptions
__init__(fail_on_resource_errors: bool = False, max_asset_size_bytes: int = 52428800, metadata_policy: MetadataRenderPolicy = <factory>, creator: str | None = 'all2md', chapter_split_mode: Literal['separator', 'heading', 'auto']='auto', chapter_split_heading_level: int = 1, title: str | None = None, author: str | None = None, language: str = 'en', identifier: str | None = None, chapter_title_template: str = 'Chapter {num}', use_heading_as_chapter_title: bool = True, generate_toc: bool = True, include_cover: bool = False, cover_image_path: str | None = None, network: NetworkFetchOptions = <factory>) None
class all2md.options.epub.EpubOptions

Bases: BaseParserOptions, AttachmentOptionsMixin

Configuration options for EPUB-to-Markdown conversion.

This dataclass contains settings specific to EPUB document processing, including chapter handling, table of contents generation, and image handling. Inherits attachment handling from AttachmentOptionsMixin for embedded images.

Parameters:
  • merge_chapters (bool, default True) – Whether to merge chapters into a single continuous document. If False, a separator is placed between chapters.

  • include_toc (bool, default True) – Whether to generate and prepend a Markdown Table of Contents.

merge_chapters: bool = True
include_toc: bool = True
html_options: HtmlOptions | None = None
__init__(attachment_mode: AttachmentMode = 'alt_text', alt_text_mode: AltTextMode = 'default', attachment_output_dir: str | None = None, attachment_base_url: str | None = None, max_asset_size_bytes: int = 52428800, attachment_filename_template: str = '{stem}_{type}{seq}.{ext}', attachment_overwrite: AttachmentOverwriteMode = 'unique', attachment_deduplicate_by_hash: bool = False, attachments_footnotes_section: str | None = 'Attachments', extract_metadata: bool = False, merge_chapters: bool = True, include_toc: bool = True, html_options: HtmlOptions | None = None) None