#!/usr/bin/env python3
"""Convert a markdown file to LaTeX & typeset it"""

import argparse
import pathlib
import shlex
import subprocess


def typeset(path: pathlib.Path) -> None:
    """Convert a markdown file to LaTeX & typeset it"""
    output = path.with_suffix(".pdf")
    subprocess.call(
        shlex.split(
            f"pandoc -t latex+smart --pdf-engine=xelatex --template=tufte_template.tex --listings {path} -o {output}"
        )
    )


if __name__ == "__main__":
    PARSER = argparse.ArgumentParser(description=__doc__)
    PARSER.add_argument("input", help="Markdown file to convert & typeset")
    typeset(pathlib.Path(PARSER.parse_args().input))
