speechmarkdown.formatters.base#
Classes#
Abstract base class for all Speech Markdown formatters. |
Module Contents#
- class speechmarkdown.formatters.base.FormatterBase(options: speechmarkdown.options.SpeechOptions)[source]#
Bases:
abc.ABCAbstract base class for all Speech Markdown formatters.
- abstractmethod format(ast: speechmarkdown.parser.ASTNode | List[speechmarkdown.parser.ASTNode]) str[source]#
Format the given AST into a string.
- addArray(ast_list: List[speechmarkdown.parser.ASTNode], lines: List[str]) List[str][source]#
Process a list of AST nodes and append output to lines.
- Parameters:
ast_list (List[ASTNode]) – List of nodes to format.
lines (List[str]) – In-progress output string list.
- Returns:
The updated lines list.
- Return type:
List[str]
- processAst(ast: speechmarkdown.parser.ASTNode | List[speechmarkdown.parser.ASTNode] | None, lines: List[str]) None[source]#
Recursively process an AST node or list of nodes.
- abstractmethod formatFromAst(ast: speechmarkdown.parser.ASTNode, lines: List[str] | None = None) List[str][source]#
Format a single AST node into output strings.
- Parameters:
ast (ASTNode) – Target formatting node.
lines (Optional[List[str]]) – Active output lines collection.
- Returns:
Updated output lines collection.
- Return type:
List[str]