Skip to content

Commit 0efac64

Browse files
committed
Created markup-languages pkg
1 parent 31cba1c commit 0efac64

22 files changed

Lines changed: 814 additions & 1 deletion

File tree

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ updates:
1313
- /get-min-py
1414
- /is-unicode-supported
1515
- /latin-locales
16+
- /markup-languages
1617
- /non-latin-locales
1718
- /programming-languages
1819
- /project-markers

docs/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# 🐍 adamlui / python-utils
44

5-
<a href="https://pypacktrends.com/?packages=find-project-root&packages=get-min-py&packages=is-unicode-supported&packages=latin-locales&packages=non-latin-locales&packages=programming-languages&packages=project-markers&packages=remove-json-keys&packages=translate-messages&time_range=allTimeCumulative&scheme=dark">
5+
<a href="https://pypacktrends.com/?packages=find-project-root&packages=get-min-py&packages=is-unicode-supported&packages=latin-locales&packages=markup-languages&packages=non-latin-locales&packages=programming-languages&packages=project-markers&packages=remove-json-keys&packages=translate-messages&time_range=allTimeCumulative&scheme=dark">
66
<img height=31 src="https://img.shields.io/badge/Downloads-9.8k-af68ff.svg?logo=weightsandbiases&logoColor=white&labelColor=464646&style=for-the-badge"></a>
77
<a href="./LICENSE.md">
88
<img height=31 src="https://img.shields.io/badge/License-MIT-f99b27.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
@@ -49,6 +49,14 @@
4949
[API usage](https://github.com/adamlui/python-utils/tree/main/latin-locales/#usage) /
5050
[Discuss](https://github.com/adamlui/python-utils/discussions)
5151

52+
### <a href="https://github.com/adamlui/python-utils/tree/main/markup-languages/#readme"><> markup-languages</a>
53+
54+
> File extensions for markup languages.
55+
<br>[Install](https://github.com/adamlui/python-utils/tree/main/markup-languages/#installation) /
56+
[Readme](https://github.com/adamlui/python-utils/tree/main/markup-languages/#readme) /
57+
[API usage](https://github.com/adamlui/python-utils/tree/main/markup-languages/#usage) /
58+
[Discuss](https://github.com/adamlui/python-utils/discussions)
59+
5260
### <a href="https://github.com/adamlui/python-utils/tree/main/non-latin-locales/#readme">🇨🇳 non-latin-locales</a>
5361

5462
> ISO 639-1 (2-letter) codes for non-Latin locales.

markup-languages/docs/LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 🏛️ MIT License
2+
3+
**Copyright © 2026 [Adam Lui](https://github.com/adamlui)**
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

markup-languages/docs/README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<a id="top"></a>
2+
3+
# > markup-languages
4+
5+
<a href="https://github.com/adamlui/python-utils/releases/tag/markup-languages-1.0.0">
6+
<img height=31 src="https://img.shields.io/badge/Latest_Build-1.0.0-32fcee.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
7+
<a href="https://github.com/adamlui/python-utils/blob/main/markup-languages/docs/LICENSE.md">
8+
<img height=31 src="https://img.shields.io/badge/License-MIT-f99b27.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
9+
<a href="https://www.codefactor.io/repository/github/adamlui/python-utils">
10+
<img height=31 src="https://img.shields.io/codefactor/grade/github/adamlui/python-utils?label=Code+Quality&logo=codefactor&logoColor=white&labelColor=464646&color=a0fc55&style=for-the-badge"></a>
11+
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_python-utils">
12+
<img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_python-utils%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=fafc74"></a>
13+
14+
> ### _File extensions for markup languages._
15+
16+
It's just a [JSON file](https://github.com/adamlui/python-utils/blob/markup-languages-1.0.0/markup-languages/src/markup_languages/markup_languages.json), so you can use it in any environment. Sourced from GitHub's [Linguist](https://github.com/github-linguist/linguist) project (defines all markdown languages known to GitHub). Data is updated via script and released via new package version.
17+
18+
## Installation
19+
20+
```bash
21+
pip install markup-languages
22+
```
23+
24+
## Usage
25+
26+
```py
27+
import markup_languages
28+
29+
html_data = markup_languages['HTML']
30+
31+
print(html_data['extensions']) # => ['.html', '.hta', '.htm', ...]
32+
```
33+
34+
_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`.
35+
36+
## Examples
37+
38+
List all extensions for a language:
39+
40+
```py
41+
html_exts = markup_languages['HTML']['extensions']
42+
43+
print(html_exts) # => ['.html', '.hta', '.htm', '.html.hl', ...]
44+
```
45+
46+
Get language from an extension:
47+
48+
```py
49+
def get_lang(file_ext):
50+
for lang, data in markup_languages.items():
51+
if file_ext in data['extensions']:
52+
return lang
53+
54+
print(get_lang('.sss')) # => 'SugarSS'
55+
```
56+
57+
Get language from a file path:
58+
59+
```py
60+
def get_lang_from_path(filepath):
61+
from pathlib import Path
62+
file_ext = Path(filepath).suffix
63+
for lang, data in markup_languages.items():
64+
if file_ext in data['extensions']:
65+
return lang
66+
67+
print(get_lang_from_path('index.html')) # => 'HTML'
68+
print(get_lang_from_path('style.css')) # => 'CSS'
69+
print(get_lang_from_path('script.js')) # => None (use programming-languages pkg)
70+
```
71+
72+
## MIT License
73+
74+
Copyright © 2026 [Adam Lui](https://github.com/adamlui).
75+
76+
## Related
77+
78+
🇨🇳 [non-latin-locales](https://github.com/adamlui/python-utils/tree/main/non-latin-locales/#readme) - ISO 639-1 (2-letter) codes for non-Latin locales.
79+
<br></> [programming-languages](https://github.com/adamlui/python-utils/tree/main/programming-languages/#readme) - File extensions for programming languages.
80+
<br>🏷️ [project-markers](https://github.com/adamlui/python-utils/tree/main/project-markers/#readme) - Common project root markers.
81+
82+
#
83+
84+
<a href="#top">Back to top ↑</a>

markup-languages/docs/SECURITY.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 🛡️ Security Policy
2+
3+
If you find a vulnerability, please e-mail security@tidelift.com and a fix will be coordinated within 2 business days.

markup-languages/noxfile.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from pathlib import Path
2+
from types import SimpleNamespace as sn
3+
4+
import nox
5+
6+
pkg = sn(dir=Path(__file__).parent.name)
7+
pkg.name = pkg.dir.replace('-', '_')
8+
paths = sn(
9+
utils=sn(bump='utils/bump.py', clean='utils/clean.py', publish='utils/publish.sh', update='utils/update_langs.py'))
10+
11+
def session(func) : return nox.session(venv_backend='none', name=func.__name__.replace('_', '-'))(func)
12+
13+
# SESSIONS
14+
15+
@session
16+
def dev(session) : session.run('pip', 'install', '-e', '.')
17+
18+
@session
19+
def lint(session) : session.run('ruff', 'check', '.', *session.posargs)
20+
@session
21+
def lint_fix(session) : session.run('ruff', 'check', '.', '--fix', *session.posargs)
22+
23+
@session
24+
def update(session, *args) : session.run('py', paths.utils.update, *args)
25+
26+
@session
27+
def bump_patch(session, no_push=True):
28+
cmd = ['py', paths.utils.bump, '--patch']
29+
if no_push : cmd.append('--no-push')
30+
session.run(*cmd, *session.posargs)
31+
@session
32+
def bump_minor(session, no_push=True):
33+
cmd = ['py', paths.utils.bump, '--minor']
34+
if no_push : cmd.append('--no-push')
35+
session.run(*cmd, *session.posargs)
36+
@session
37+
def bump_feat(session, no_push=True):
38+
bump_minor(session, no_push)
39+
@session
40+
def bump_major(session, no_push=True):
41+
cmd = ['py', paths.utils.bump, '--major']
42+
if no_push : cmd.append('--no-push')
43+
session.run(*cmd, *session.posargs)
44+
45+
@session
46+
def build(session) : clean(session) ; session.run('py', '-m', 'build') ; print('Build complete!')
47+
@session
48+
def publish(session) : session.run('bash', paths.utils.publish, *session.posargs)
49+
50+
@session
51+
def deploy_patch(session) : bump_patch(session, no_push=False) ; build(session) ; publish(session)
52+
@session
53+
def deploy_minor(session) : bump_minor(session, no_push=False) ; build(session) ; publish(session)
54+
@session
55+
def deploy_feat(session) : deploy_minor(session)
56+
@session
57+
def deploy_major(session) : bump_major(session, no_push=False) ; build(session) ; publish(session)
58+
59+
@session
60+
def clean(session, *args) : session.run('py', paths.utils.clean, *args)

markup-languages/pyproject.toml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
[build-system]
2+
requires = [
3+
"setuptools~=82.0.0",
4+
"wheel",
5+
]
6+
build-backend = "setuptools.build_meta"
7+
8+
[project]
9+
name = "markup-languages"
10+
version = "1.0.0"
11+
description = "File extensions for markup languages."
12+
authors = [
13+
{ name = "Adam Lui", email = "adam@kudoai.com" },
14+
]
15+
readme = "docs/README.md"
16+
license = "MIT"
17+
license-files = [
18+
"docs/LICENSE.md",
19+
]
20+
requires-python = ">=2.6,<4"
21+
keywords = [
22+
"computer-languages",
23+
"css",
24+
"extensions",
25+
"file-extensions",
26+
"file‑type-detection",
27+
"filenames",
28+
"github",
29+
"html",
30+
"language-detection",
31+
"languages",
32+
"linguist",
33+
"markup-languages",
34+
"syntax-highlighting",
35+
"xml",
36+
]
37+
classifiers = [
38+
"Development Status :: 5 - Production/Stable",
39+
"Intended Audience :: Developers",
40+
"Intended Audience :: Education",
41+
"Intended Audience :: Information Technology",
42+
"Intended Audience :: Science/Research",
43+
"Intended Audience :: System Administrators",
44+
"Natural Language :: English",
45+
"Operating System :: OS Independent",
46+
"Programming Language :: Python",
47+
"Programming Language :: Python :: 2",
48+
"Programming Language :: Python :: 2.6",
49+
"Programming Language :: Python :: 2.7",
50+
"Programming Language :: Python :: 3",
51+
"Programming Language :: Python :: 3.8",
52+
"Programming Language :: Python :: 3.9",
53+
"Programming Language :: Python :: 3.10",
54+
"Programming Language :: Python :: 3.11",
55+
"Programming Language :: Python :: 3.12",
56+
"Programming Language :: Python :: 3.13",
57+
"Programming Language :: Python :: 3.14",
58+
"Programming Language :: Python :: 3.15",
59+
"Topic :: Education",
60+
"Topic :: Software Development",
61+
"Topic :: Software Development :: Libraries",
62+
"Topic :: Software Development :: Libraries :: Python Modules",
63+
"Topic :: Text Processing",
64+
"Topic :: Text Processing :: Markup",
65+
"Topic :: Utilities",
66+
]
67+
68+
[project.urls]
69+
Changelog = "https://github.com/adamlui/python-utils/releases/tag/markup-languages-1.0.0"
70+
Documentation = "https://github.com/adamlui/python-utils/tree/main/markup-languages/docs"
71+
Funding = "https://github.com/sponsors/adamlui"
72+
Homepage = "https://github.com/adamlui/python-utils/tree/main/markup-languages/#readme"
73+
Issues = "https://github.com/adamlui/python-utils/issues"
74+
"PyPI Stats" = "https://pepy.tech/projects/markup-languages"
75+
Releases = "https://github.com/adamlui/python-utils/releases"
76+
Repository = "https://github.com/adamlui/python-utils"
77+
78+
[project.optional-dependencies]
79+
dev = [
80+
"nox>=2026.2.9",
81+
"tomli~=2.4.0",
82+
"tomli-w~=1.2.0",
83+
]
84+
85+
[tool.setuptools.packages.find]
86+
where = [
87+
"src",
88+
]
89+
90+
[tool.setuptools.package-data]
91+
markup_languages = [
92+
"markup_languages.json",
93+
]

markup-languages/setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[bdist_wheel]
2+
universal = 1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import json, os, sys
2+
3+
with open(os.path.join(os.path.dirname(__file__), 'markup_languages.json')) as file:
4+
markup_languages = json.load(file)
5+
6+
sys.modules[__name__] = markup_languages
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"API Blueprint": { "extensions": [".apib"] },
3+
"Antlers": { "extensions": [".antlers.html",".antlers.php",".antlers.xml"] },
4+
"Astro": { "extensions": [".astro"] },
5+
"BibTeX": { "extensions": [".bib",".bibtex"] },
6+
"Bikeshed": { "extensions": [".bs"] },
7+
"Blade": { "extensions": [".blade",".blade.php"] },
8+
"Bru": { "extensions": [".bru"] },
9+
"CSS": { "extensions": [".css"] },
10+
"Closure Templates": { "extensions": [".soy"] },
11+
"Cooklang": { "extensions": [".cook"] },
12+
"D2": { "extensions": [".d2"] },
13+
"EJS": { "extensions": [".ejs",".ect",".ejs.t",".jst"] },
14+
"Ecmarkup": { "extensions": [".html"] },
15+
"Edge": { "extensions": [".edge"] },
16+
"Genero per": { "extensions": [".per"] },
17+
"Go Template": { "extensions": [".gohtml",".gotmpl",".html.tmpl",".tmpl",".tpl"] },
18+
"HTML": { "extensions": [".html",".hta",".htm",".html.hl",".inc",".xht",".xhtml"] },
19+
"HTML+ECR": { "extensions": [".ecr"] },
20+
"HTML+EEX": { "extensions": [".html.eex",".heex",".leex"] },
21+
"HTML+ERB": { "extensions": [".erb",".erb.deface",".rhtml"] },
22+
"HTML+PHP": { "extensions": [".phtml"] },
23+
"HTML+Razor": { "extensions": [".cshtml",".razor"] },
24+
"Haml": { "extensions": [".haml",".haml.deface"] },
25+
"Handlebars": { "extensions": [".handlebars",".hbs"] },
26+
"Jinja": { "extensions": [".jinja",".j2",".jinja2"] },
27+
"Jupyter Notebook": { "extensions": [".ipynb"] },
28+
"Kit": { "extensions": [".kit"] },
29+
"Latte": { "extensions": [".latte"] },
30+
"Less": { "extensions": [".less"] },
31+
"Liquid": { "extensions": [".liquid"] },
32+
"MDX": { "extensions": [".mdx"] },
33+
"MTML": { "extensions": [".mtml"] },
34+
"Marko": { "extensions": [".marko"] },
35+
"Mask": { "extensions": [".mask"] },
36+
"Mermaid": { "extensions": [".mmd",".mermaid"] },
37+
"Mustache": { "extensions": [".mustache"] },
38+
"Nunjucks": { "extensions": [".njk"] },
39+
"Pic": { "extensions": [".pic",".chem"] },
40+
"PostCSS": { "extensions": [".pcss",".postcss"] },
41+
"PostScript": { "extensions": [".ps",".eps",".epsi",".pfa"] },
42+
"Pug": { "extensions": [".jade",".pug"] },
43+
"RAML": { "extensions": [".raml"] },
44+
"RUNOFF": { "extensions": [".rnh",".rno"] },
45+
"Rich Text Format": { "extensions": [".rtf"] },
46+
"Riot": { "extensions": [".riot"] },
47+
"Roff": {
48+
"extensions": [
49+
".roff", ".1", ".1in", ".1m", ".1x", ".2", ".3", ".3in", ".3m", ".3p", ".3pm", ".3qt", ".3x", ".4", ".5", ".6",
50+
".7", ".8", ".9", ".l", ".man", ".mdoc", ".me", ".ms", ".n", ".nr", ".rno", ".tmac"
51+
]
52+
},
53+
"Roff Manpage": {
54+
"extensions": [
55+
".1", ".1in", ".1m", ".1x", ".2", ".3", ".3in", ".3m", ".3p", ".3pm", ".3qt", ".3x", ".4", ".5", ".6", ".7", ".8",
56+
".9", ".man", ".mdoc"
57+
]
58+
},
59+
"SCSS": { "extensions": [".scss"] },
60+
"SRecode Template": { "extensions": [".srt"] },
61+
"Sass": { "extensions": [".sass"] },
62+
"Scaml": { "extensions": [".scaml"] },
63+
"Slim": { "extensions": [".slim"] },
64+
"Slint": { "extensions": [".slint"] },
65+
"StringTemplate": { "extensions": [".st"] },
66+
"Stylus": { "extensions": [".styl"] },
67+
"SugarSS": { "extensions": [".sss"] },
68+
"Svelte": { "extensions": [".svelte"] },
69+
"TeX": {
70+
"extensions": [".tex",".aux",".bbx",".cbx",".cls",".dtx",".ins",".lbx",".ltx",".mkii",".mkiv",".mkvi",".sty",".toc"]
71+
},
72+
"Tea": { "extensions": [".tea"] },
73+
"Terraform Template": { "extensions": [".tftpl"] },
74+
"Twig": { "extensions": [".twig"] },
75+
"Velocity Template Language": { "extensions": [".vtl"] },
76+
"Vento": { "extensions": [".vto"] },
77+
"Vim Snippet": { "extensions": [".snip",".snippet",".snippets"] },
78+
"Vue": { "extensions": [".vue"] },
79+
"YASnippet": { "extensions": [".yasnippet"] },
80+
"kvlang": { "extensions": [".kv"] },
81+
"mdsvex": { "extensions": [".svx"] },
82+
"templ": { "extensions": [".templ"] }
83+
}

0 commit comments

Comments
 (0)