Command Line¶
The rtfstruct command converts RTF files to Markdown, JSON, diagnostics, or
normalized RTF.
rtfstruct input.rtf --to markdown > output.md
rtfstruct input.rtf --to json --output output.json
rtfstruct input.rtf --to diagnostics
rtfstruct input.rtf --to rtf --output normalized.rtf
Use --track-spans when JSON output should include source offsets for supported
AST nodes.
rtfstruct input.rtf --to json --track-spans
Command-line entry point for rtfstruct.
- rtfstruct.cli.build_parser()[source]¶
Build the command-line argument parser.
- Returns:
Configured argument parser for the rtfstruct command.
- Return type:
ArgumentParser
- rtfstruct.cli.main(argv=None, stdout=None, stderr=None)[source]¶
Run the rtfstruct command-line interface.
- Parameters:
argv (list[str] | None) – Optional argument list. Defaults to sys.argv[1:].
stdout (TextIO | None) – Optional text stream for standard output.
stderr (TextIO | None) – Optional text stream for standard error.
- Returns:
Process exit code.
- Return type:
int