md2star.templates module

md2star templates {list,path} — inspect bundled / cached / per-project templates.

Module summary

A diagnostic CLI verb that mirrors the resolution order of md2star.cli._resolve_reference_doc without actually converting anything. Two sub-verbs:

  • md2star templates list — prints a table of every template resolution candidate (per-project / cached / bundled) and whether it exists. Distinguishes docx from pptx rows so you can see at a glance which format is missing its template.

  • md2star templates path [--fmt {docx,pptx}] [INPUT] — prints the absolute filesystem path of the template that md2star WOULD use for the given input (default: current directory + docx). One line, parseable by shell scripts.

The motivation is the recurring “why isn’t my branding applied?” debug loop. Before this command, users had to read the _resolve_reference_doc docstring and re-derive the priority order in their head. Now they md2star templates path file.md and md2star tells them.

Usage

>>> # From the shell:
>>> #   md2star templates list
>>> #   md2star templates path report.md --fmt docx
>>> # gives you the per-format resolution table and the resolved
>>> # path that `md2docx report.md` would pick up.

Author

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

md2star.templates.cmd_list(args)[source]

Print a per-format resolution table to stdout.

Walks the same candidate chain as the conversion path, marks each existing file with , marks the first existing one as the active winner with . No conversion, no network.

Parameters:

args (Namespace)

Return type:

int

md2star.templates.cmd_path(args)[source]

Print the absolute path of the active template for fmt.

Useful for shell scripts that want to operate on the template md2star is currently using (e.g. opening it in Word for branding). Exits with code 2 + a stderr message if no template exists at any of the candidate locations (an install bug).

Parameters:

args (Namespace)

Return type:

int

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

Console entry point: md2star templates {list,path}.

Parameters:

argv (list[str] | None)

Return type:

int