Skip to main content

File extensions for markup languages.

Project description

> markup-languages

File extensions for markup languages.

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

Installation

pip install markup-languages

Usage

import markup_languages

html_lang_data = markup_languages['HTML']

print(html_lang_data['extensions']) # => ['.hta', '.htm', '.html', '.html.hl', ...]

Note: Most type checkers will falsely warn markup_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 markup_languages.items():
        if file_ext in data['extensions']:
            return lang

print(get_lang('.sss')) # => 'SugarSS'

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 markup_languages.items():
        if file_ext in data['extensions']:
            return lang

print(get_lang_from_path('index.html')) # => 'HTML'
print(get_lang_from_path('style.css'))  # => 'CSS'
print(get_lang_from_path('script.js'))  # => None (use programming-languages pkg)

MIT License

Copyright © 2026 Adam Lui

Related

🇨🇳 non-latin-locales - ISO 639-1 (2-letter) codes for non-Latin locales.
#! programming-languages - File extensions for programming languages.
🏷️ project-markers - Common project root markers.

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

markup_languages-1.0.3.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

markup_languages-1.0.3-py2.py3-none-any.whl (5.7 kB view details)

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for markup_languages-1.0.3.tar.gz
Algorithm Hash digest
SHA256 76b5fa8e83f6c12d05b87f8e141409e2950d579985bed7b7bc58c68c76ed2750
MD5 d65f7204dd68f4cfe56a9ffb8d67be2d
BLAKE2b-256 a6c8d6f1ba15be81377e3b35256ec77c22be00a824c3c1ed81929637ba6e38c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for markup_languages-1.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 62be0de2ce0db0fcc7695f68af1005526768e272b0139d2540ea830710f32777
MD5 e6b89e21bc92c0e4c8b703567662c7ac
BLAKE2b-256 ab1ff43e028d9f94e7776f0f44fa1b518d155d5bd8af9cd5d5ecfc9ff07943c0

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