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.2.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.2-py2.py3-none-any.whl (5.0 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

  • Download URL: prose_languages-1.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 0d2f02d64e37cfab1a7fbfc18b4b7261733d19a1601189f55be5efa25bd28e06
MD5 d4c5047ab2980600f7eb651525d33925
BLAKE2b-256 f182b27315c9fd55fb5b58934623a4400691ff4eb1598cfe8145ac66ef1d6e22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for prose_languages-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a38f55d86b26e99d7954c56be769a8721b47b6962e08331bc718ad0f56a336cb
MD5 2704a279da16e14649c4a6fa4953c1f3
BLAKE2b-256 897460d581f8861af5a790ba2a4c61a019a926973b7126fd19c7f9dea11a1611

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