md2star.cli module

md2star’s command line, built with click.

One parser, one surface. Until 3.10.0 this module held an argparse front-end and the conversion engine, while a second module (click_cli.py) offered a click façade that rebuilt an argv string list and handed it back here to be re-parsed. Two parsers for one command line meant two places to add a flag — and by the end, five commands and nine options existed on only one of them.

Now the parsing happens once, here, and the engine lives in md2star.pipeline behind a typed ConvertOptions.

Console entry points ([project.scripts] in pyproject.toml):

The three md2<fmt> entries are not aliases of a single command: they are the same click command object, reachable either as md2star docx or as md2docx, so a flag can never exist on one spelling and not the other.

The Pandoc passthrough

md2star’s defining behaviour is that flags it does not recognise go straight to Pandoc. argparse did that with parse_known_args; click is strict by default, so each converter is declared with context_settings={"ignore_unknown_options": True} and swallows everything into one nargs=-1, type=click.UNPROCESSED argument, which _split_input() then separates into “the input file” and “Pandoc’s problem”. See that function for why the split is positional rather than clever.

Author

[Warith HARCHAOUI](https://linkedin.com/in/warith-harchaoui/)

md2star.cli.cache_dir_command()

Print the resolved cache directory path.

Return type:

None

md2star.cli.clear_cache_command()

Wipe the cache directory (templates, resized rasters, mermaid renders).

Return type:

None

md2star.cli.main(argv=None)[source]

Console entry point: md2star <command> [...].

Parameters:

argv (Sequence[str] | None)

Return type:

int

md2star.cli.md2docx_main(argv=None)[source]

Console entry point: md2docx <input.md> [options...].

Parameters:

argv (Sequence[str] | None)

Return type:

int

md2star.cli.md2pdf_main(argv=None)[source]

Console entry point: md2pdf <input.md> [options...].

Parameters:

argv (Sequence[str] | None)

Return type:

int

md2star.cli.md2pptx_main(argv=None)[source]

Console entry point: md2pptx <input.md> [options...].

Parameters:

argv (Sequence[str] | None)

Return type:

int

md2star.cli.templates()

Inspect bundled / cached / per-project templates without converting.

Return type:

None