Skip to main content

File extensions for prose languages.

Project description

> prose-languages

File extensions for prose languages.

It's just a JSON file, so you can use it in any environment. Sourced from GitHub's Linguist project (defines all 18 prose languages known to GitHub). Data is updated via script and released via new package version.

Installation

pip install prose-languages

Usage

import prose_languages

md_lang_data = prose_languages['Markdown']

print(md_lang_data['extensions']) # => ['.livemd', '.markdown', '.md', ...]

Note: Most type checkers will falsely warn prose_languages is not subscriptable because they are incapable of analyzing runtime behavior (where the module is replaced w/ a dictionary for cleaner, direct access). You can safely suppress such warnings using # type: ignore.

Examples

Get language from an extension:

def get_lang(file_ext):
    for lang, data in prose_languages.items():
        if file_ext in data['extensions']:
            return lang

print(get_lang('.gmi')) # => Gemini

Get language from a file path:

def get_lang_from_path(filepath):
    from pathlib import Path
    file_ext = Path(filepath).suffix
    for lang, data in prose_languages.items():
        if file_ext in data['extensions']:
            return lang

print(get_lang_from_path('document.adoc')) # => AsciiDoc
print(get_lang_from_path('README.md')) # => Markdown
print(get_lang_from_path('index.mdx')) # => None (use markup-languages pkg)

MIT License

Copyright © 2026 Adam Lui

Related

</> markup-languages - File extensions for markup languages.
#! programming-languages - File extensions for programming languages.
{ } data-languages - File extensions for data languages.

More Python utilities / Discuss / Report bug / Report vulnerability / Back to top ↑

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prose_languages-1.0.3.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

prose_languages-1.0.3-py2.py3-none-any.whl (5.1 kB view details)

Uploaded Python 2Python 3

File details

Details for the file prose_languages-1.0.3.tar.gz.

File metadata

  • Download URL: prose_languages-1.0.3.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for prose_languages-1.0.3.tar.gz
Algorithm Hash digest
SHA256 7b9c40ea122701719bafce9a72201ed88908b9102f5731e63776a5ea24193e28
MD5 f7d37ac234c357542668fe59258a9055
BLAKE2b-256 af261c84d0833c873073bad56590126da3803e726e3da957dac7984f38a941b4

See more details on using hashes here.

File details

Details for the file prose_languages-1.0.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for prose_languages-1.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 617f6707dae611b7035db523abb8e8862b7e41233d5e0026717605bfb17b998f
MD5 c92ecf67a2b32c5ed18018e16b7ec20b
BLAKE2b-256 101c002cfadfab402459bba9d384b1c0c7665681b95dcebf8a490cde9dd97a0b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page