all2md.options.plaintext

Configuration options for plain text rendering.

This module defines options for rendering AST to plain text format.

class all2md.options.plaintext.PlainTextParserOptions

Bases: BaseParserOptions

Configuration options for plain text parsing.

Parameters:

preserve_single_newlines (bool, default False) – Preserve single newlines characters in text

preserve_single_newlines: bool = False
__init__(extract_metadata: bool = False, preserve_single_newlines: bool = False) None
class all2md.options.plaintext.PlainTextOptions

Bases: BaseRendererOptions

Configuration options for plain text rendering.

This dataclass contains settings for rendering AST documents as plain, unformatted text. All formatting (bold, italic, headings, etc.) is stripped, leaving only the text content.

Parameters:
  • max_line_width (int or None, default 80) – Maximum line width for wrapping text. Set to None to disable wrapping. When enabled, long lines will be wrapped at word boundaries.

  • table_cell_separator (str, default " | ") – Separator string to use between table cells.

  • include_table_headers (bool, default True) – Whether to include table headers in the output. When False, only table body rows are rendered.

  • paragraph_separator (str, default "nn") – Separator string to use between paragraphs and block elements.

  • list_item_prefix (str, default "- ") – Prefix to use for list items (both ordered and unordered).

  • preserve_code_blocks (bool, default True) – Whether to preserve code block content with original formatting. When False, code blocks are treated like regular paragraphs.

  • preserve_blank_lines (bool, default True) – Whether to preserve consecutive blank lines in the output. When False, consecutive blank lines are collapsed according to paragraph_separator. When True, provides literal pass-through of blank lines for consumers that need exact whitespace preservation.

  • comment_mode ({"visible", "ignore"}, default "ignore") – How to render Comment and CommentInline AST nodes: - “visible”: Render as bracketed text - “ignore”: Skip comments entirely (default)

Examples

Basic plain text rendering:
>>> from all2md.ast import Document, Paragraph, Text
>>> from all2md.renderers.plaintext import PlainTextRenderer
>>> from all2md.options import PlainTextOptions
>>> doc = Document(children=[
...     Paragraph(content=[Text(content="Hello world")])
... ])
>>> options = PlainTextOptions(max_line_width=None)
>>> renderer = PlainTextRenderer(options)
>>> text = renderer.render_to_string(doc)
max_line_width: int | None = 80
table_cell_separator: str = ' | '
include_table_headers: bool = True
paragraph_separator: str = '\n\n'
list_item_prefix: str = '- '
preserve_code_blocks: bool = True
preserve_blank_lines: bool = True
comment_mode: Literal['visible', 'ignore'] = 'ignore'
__init__(fail_on_resource_errors: bool = False, max_asset_size_bytes: int = 52428800, metadata_policy: MetadataRenderPolicy = <factory>, creator: str | None = 'all2md', max_line_width: int | None = 80, table_cell_separator: str = ' | ', include_table_headers: bool = True, paragraph_separator: str = '\n\n', list_item_prefix: str = '- ', preserve_code_blocks: bool = True, preserve_blank_lines: bool = True, comment_mode: Literal['visible', 'ignore']='ignore') None