all2md.parsers.fb2

FB2 (FictionBook 2.0) parser that converts FB2 ebooks to AST representation.

class all2md.parsers.fb2.Fb2ToAstConverter

Bases: BaseParser

Convert FB2 ebooks to AST representation.

Initialize the FB2 to AST converter.

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

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

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

Initialize the FB2 to AST converter.

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

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

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

Parse FB2 document into an AST Document.

convert_to_ast(root: ET.Element) Document

Convert parsed FB2 XML tree to AST Document.

extract_metadata(document: ET.Element) DocumentMetadata

Extract metadata from FB2 XML tree.