all2md.options.eml
Configuration options for EML (email) parsing.
This module defines options for parsing email files and message chains.
- class all2md.options.eml.EmlOptions
Bases:
BaseParserOptions,AttachmentOptionsMixinConfiguration options for EML-to-Markdown conversion.
This dataclass contains settings specific to email message processing, including robust parsing, date handling, quote processing, and URL cleaning. Inherits attachment handling from AttachmentOptionsMixin for email attachments.
- Parameters:
include_headers (bool, default True) – Whether to include email headers (From, To, Subject, Date) in output.
preserve_thread_structure (bool, default True) – Whether to maintain email thread/reply chain structure.
date_format_mode ({"iso8601", "locale", "strftime"}, default "strftime") – How to format dates in output: - “iso8601”: Use ISO 8601 format (2023-01-01T10:00:00Z) - “locale”: Use system locale-aware formatting - “strftime”: Use custom strftime pattern
date_strftime_pattern (str, default "%m/%d/%y %H:%M") – Custom strftime pattern when date_format_mode is “strftime”.
convert_html_to_markdown (bool, default False) – Whether to convert HTML content to Markdown When True, HTML parts are converted to Markdown; when False, HTML is preserved as-is.
clean_quotes (bool, default True) – Whether to clean and normalize quoted content (”> “ prefixes, etc.).
detect_reply_separators (bool, default True) – Whether to detect common reply separators like “On <date>, <name> wrote:”.
normalize_headers (bool, default True) – Whether to normalize header casing and whitespace.
preserve_raw_headers (bool, default False) – Whether to preserve both raw and decoded header values.
clean_wrapped_urls (bool, default True) – Whether to clean URL defense/safety wrappers from links.
url_wrappers (list[str], default from constants) – List of URL wrapper domains to clean (urldefense.com, safelinks, etc.).
Examples
- Convert email with ISO 8601 date formatting:
>>> options = EmlOptions(date_format_mode="iso8601")
- Convert with HTML-to-Markdown conversion enabled:
>>> options = EmlOptions(convert_html_to_markdown=True)
- Disable quote cleaning and URL unwrapping:
>>> options = EmlOptions(clean_quotes=False, clean_wrapped_urls=False)
- include_headers: bool = True
- preserve_thread_structure: bool = True
- date_format_mode: Literal['iso8601', 'locale', 'strftime'] = 'strftime'
- date_strftime_pattern: str = '%m/%d/%y %H:%M'
- convert_html_to_markdown: bool = False
- clean_quotes: bool = True
- detect_reply_separators: bool = True
- normalize_headers: bool = True
- preserve_raw_headers: bool = False
- clean_wrapped_urls: bool = True
- url_wrappers: list[str] | None
- html_network: NetworkFetchOptions
- sort_order: Literal['asc', 'desc'] = 'asc'
- subject_as_h1: bool = True
- include_attach_section_heading: bool = True
- attach_section_title: str = 'Attachments'
- include_html_parts: bool = True
- include_plain_parts: bool = True
- include_rtf_parts: bool = True
- __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, include_headers: bool = True, preserve_thread_structure: bool = True, date_format_mode: DateFormatMode = 'strftime', date_strftime_pattern: str = '%m/%d/%y %H:%M', convert_html_to_markdown: bool = False, clean_quotes: bool = True, detect_reply_separators: bool = True, normalize_headers: bool = True, preserve_raw_headers: bool = False, clean_wrapped_urls: bool = True, url_wrappers: list[str] | None = <factory>, html_network: NetworkFetchOptions = <factory>, sort_order: EmailSortOrder = 'asc', subject_as_h1: bool = True, include_attach_section_heading: bool = True, attach_section_title: str = 'Attachments', include_html_parts: bool = True, include_plain_parts: bool = True, include_rtf_parts: bool = True) None