all2md.options.yaml

Options for YAML parsing and rendering.

This module defines configuration options for converting between YAML and AST. The parser converts YAML structures to readable document format, while the renderer extracts tables and structured data from documents back to YAML.

class all2md.options.yaml.YamlParserOptions

Bases: BaseParserOptions

Configuration options for YAML to AST parsing.

By default the parser emits the YAML as a fenced code block (literal_block). Set literal_block=False to convert YAML structures into a human-readable document instead: - Objects/dicts become heading hierarchies - Arrays of objects become tables - Arrays of primitives become lists - Nested structures become subsections

Parameters:
  • max_heading_depth (int, default = 6) – Maximum nesting depth for headings. Deeper structures will be rendered as definition lists or nested paragraphs instead of headings.

  • array_as_table_threshold (int, default = 1) – Minimum number of items in an array to render it as a table (for arrays of objects with consistent keys). Set to 2 or higher to render single-item arrays as definition lists instead of tables.

  • flatten_single_keys (bool, default = True) – If True, flatten objects that contain only a single key. For example, {“wrapper”: {“actual_data”: “value”}} becomes “# actual_data” instead of “# wrapper” > “## actual_data”.

  • include_type_hints (bool, default = False) – If True, add metadata hints about the original YAML types (useful for round-trip conversion or debugging).

  • pretty_format_numbers (bool, default = True) – If True, format large numbers with thousand separators for readability.

  • sort_keys (bool, default = False) – If True, sort object keys alphabetically when rendering.

  • literal_block (bool, default = True) – If True (the default), render YAML as a literal fenced code block, preserving the native syntax. Set to False to convert into a structured document (headings, tables for arrays of objects, lists).

literal_block: bool = True
max_heading_depth: int = 6
array_as_table_threshold: int = 1
flatten_single_keys: bool = True
include_type_hints: bool = False
pretty_format_numbers: bool = True
sort_keys: bool = False
__init__(extract_metadata: bool = False, literal_block: bool = True, max_heading_depth: int = 6, array_as_table_threshold: int = 1, flatten_single_keys: bool = True, include_type_hints: bool = False, pretty_format_numbers: bool = True, sort_keys: bool = False) None
class all2md.options.yaml.YamlRendererOptions

Bases: BaseRendererOptions

Configuration options for AST to YAML rendering.

The renderer extracts structured data from markdown documents, primarily focusing on tables but optionally including lists and other elements.

Parameters:
  • extract_mode (Literal["tables", "lists", "both"], default = "tables") – What to extract from the document: - “tables”: Extract only tables as arrays of objects - “lists”: Extract only lists as arrays - “both”: Extract both tables and lists

  • type_inference (bool, default = True) – If True, automatically detect and convert types (numbers, booleans, null). If False, all values remain as strings.

  • table_heading_keys (bool, default = True) – If True, use the preceding heading text as the key name for each table. If False, tables are stored in a flat array.

  • flatten_single_table (bool, default = False) – If True and only one table is found, return the array directly instead of wrapping it in an object with a key.

  • include_table_metadata (bool, default = False) – If True, include metadata about table position, source heading, etc.

  • indent (int | None, default = 2) – Number of spaces for YAML indentation. None for default YAML formatting.

  • default_flow_style (bool | None, default = False) – YAML flow style (inline braces/brackets). False for block style (default), True for flow style, None for automatic selection.

  • sort_keys (bool, default = False) – If True, sort keys in output YAML.

extract_mode: Literal['tables', 'lists', 'both'] = 'tables'
type_inference: bool = True
table_heading_keys: bool = True
flatten_single_table: bool = False
include_table_metadata: bool = False
indent: int | None = 2
default_flow_style: bool | None = False
sort_keys: bool = False
__init__(fail_on_resource_errors: bool = False, max_asset_size_bytes: int = 52428800, metadata_policy: MetadataRenderPolicy = <factory>, creator: str | None = 'all2md', extract_mode: Literal['tables', 'lists', 'both']='tables', type_inference: bool = True, table_heading_keys: bool = True, flatten_single_table: bool = False, include_table_metadata: bool = False, indent: int | None = 2, default_flow_style: bool | None = False, sort_keys: bool = False) None