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 / 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.1.tar.gz (5.6 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.1-py2.py3-none-any.whl (5.0 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: prose_languages-1.0.1.tar.gz
  • Upload date:
  • Size: 5.6 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.1.tar.gz
Algorithm Hash digest
SHA256 9bf2873ec58f159e351d9726de5cb8d48be69d34df7622604e6d11094de1add7
MD5 1819c23dbca4f08949fe22b59413e44a
BLAKE2b-256 ae1f01b9d506012f69c574ad19bc0ecd44e488cfb5aed3f95f03d683e5df6be6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prose_languages-1.0.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f7ad9a740ba4c3ed41a86276574684e170cc00899c961980b2d5ce549575c9d3
MD5 787309fee58f7b27a5fd492a382cba78
BLAKE2b-256 b146127bb5814170c35b7070fd357f367a02f8393f6c0b6a99ac8bb66a8fda2e

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