in2lambda.main.file_typeยถ

in2lambda.main.file_type(file: str) str[source]ยถ

Determines which pandoc file format to use for a given file.

See https://github.com/jgm/pandoc/blob/bad922a69236e22b20d51c4ec0b90c5a6c038433/src/Text/Pandoc/Format.hs#L171 (or any newer commit) for pandocโ€™s supported file extensions.

Parameters:

file โ€“ A file path with the file extension included.

Returns:

An option in pandoc โ€“list-input-formats that matches the given file type

Examples

>>> from in2lambda.main import file_type
>>> file_type("example.tex")
'latex'
>>> file_type("/some/random/path/demo.md")
'markdown'
>>> file_type("no_extension")
Traceback (most recent call last):
RuntimeError: Unsupported file extension: .no_extension
>>> file_type("demo.unknown_extension")
Traceback (most recent call last):
RuntimeError: Unsupported file extension: .unknown_extension