all2md.parsers.textile

Textile to AST converter.

This module provides conversion from Textile markup to AST representation using the textile library. It enables bidirectional transformation by parsing Textile documents into the same AST structure used for other formats.

class all2md.parsers.textile.TextileParser

Bases: BaseParser

Convert Textile markup to AST representation.

This converter uses the textile library to convert Textile markup to HTML, then leverages the existing HtmlToAstConverter to build an AST that matches the structure used throughout all2md, enabling bidirectional conversion and transformation pipelines.

Parameters:
  • options (TextileParserOptions or None, default = None) – Parser configuration options

  • progress_callback (ProgressCallback or None, default = None) – Optional callback for progress updates

Examples

Basic parsing:

>>> parser = TextileParser()
>>> doc = parser.parse("h1. Title\n\nThis is *bold*.")

With options:

>>> options = TextileParserOptions(strict_mode=True)
>>> parser = TextileParser(options)
>>> doc = parser.parse(textile_text)

Initialize the Textile parser with options and progress callback.

__init__(options: TextileParserOptions | None = None, progress_callback: Callable[[ProgressEvent], None] | None = None)

Initialize the Textile parser with options and progress callback.

parse(input_data: str | Path | IO[bytes] | bytes) Document

Parse Textile input into AST Document.

Parameters:

input_data (str, Path, IO[bytes], or bytes) – Textile input to parse. Can be: - File path (str or Path) - File-like object in binary mode - Raw Textile bytes - Textile string

Returns:

AST document node

Return type:

Document

Raises:
extract_metadata(document: Any) DocumentMetadata

Extract metadata from Textile document.

Textile doesn’t have standard metadata fields, but we can try to extract basic information like title from the first heading.

Parameters:

document (Any) – Document content or AST

Returns:

Extracted metadata

Return type:

DocumentMetadata