Skip to content

Commit 5835899

Browse files
committed
Created prose-languages pkg
1 parent 41b4fe5 commit 5835899

22 files changed

Lines changed: 760 additions & 0 deletions

.github/dependabot.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ updates:
1818
- /non-latin-locales
1919
- /programming-languages
2020
- /project-markers
21+
- /prose-languages
2122
- /remove-json-keys
2223
- /translate-messages
2324
schedule:

docs/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@
8989
[API usage](https://github.com/adamlui/python-utils/tree/main/project-markers/#usage) /
9090
[Discuss](https://github.com/adamlui/python-utils/discussions)
9191

92+
### <a href="https://github.com/adamlui/python-utils/tree/main/prose-languages/#readme">## prose-languages</a>
93+
94+
> File extensions for prose languages.
95+
<br>[Install](https://github.com/adamlui/python-utils/tree/main/prose-languages/#installation) /
96+
[Readme](https://github.com/adamlui/python-utils/tree/main/prose-languages/#readme) /
97+
[API usage](https://github.com/adamlui/python-utils/tree/main/prose-languages/#usage) /
98+
[Discuss](https://github.com/adamlui/python-utils/discussions)
99+
92100
### <a href="https://github.com/adamlui/python-utils/tree/main/remove-json-keys/#readme">{ } remove-json-keys</a>
93101

94102
> Simply remove JSON keys via CLI command.

prose-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.

prose-languages/docs/README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<a id="top"></a>
2+
3+
# > prose-languages
4+
5+
<a href="https://github.com/adamlui/python-utils/releases/tag/prose-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/prose-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 prose languages._
15+
16+
It's just a [JSON file](https://github.com/adamlui/python-utils/blob/prose-languages-1.0.0/prose-languages/src/prose_languages/prose_languages.json), so you can use it in any environment. Sourced from GitHub's [Linguist](https://github.com/github-linguist/linguist) project (defines all 18 prose languages known to GitHub). Data is updated via script and released via new package version.
17+
18+
## Installation
19+
20+
```bash
21+
pip install prose-languages
22+
```
23+
24+
## Usage
25+
26+
```py
27+
import prose_languages
28+
29+
md_data = prose_languages['Markdown']
30+
31+
print(md_data['extensions']) # => ['.livemd', '.markdown', '.md', ...]
32+
```
33+
34+
_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`.
35+
36+
## Examples
37+
38+
Get language from an extension:
39+
40+
```py
41+
def get_lang(file_ext):
42+
for lang, data in prose_languages.items():
43+
if file_ext in data['extensions']:
44+
return lang
45+
46+
print(get_lang('.gmi')) # => 'Gemini'
47+
```
48+
49+
Get language from a file path:
50+
51+
```py
52+
def get_lang_from_path(filepath):
53+
from pathlib import Path
54+
file_ext = Path(filepath).suffix
55+
for lang, data in prose_languages.items():
56+
if file_ext in data['extensions']:
57+
return lang
58+
59+
print(get_lang_from_path('document.adoc')) # => 'AsciiDoc'
60+
print(get_lang_from_path('README.md')) # => 'Markdown'
61+
print(get_lang_from_path('index.mdx')) # => None (use markup-languages pkg)
62+
```
63+
64+
## MIT License
65+
66+
Copyright © 2026 [Adam Lui](https://github.com/adamlui).
67+
68+
## Related
69+
70+
</> [markup-languages](https://github.com/adamlui/python-utils/tree/main/markup-languages/#readme) - File extensions for markup languages.
71+
<br>#! [programming-languages](https://github.com/adamlui/python-utils/tree/main/programming-languages/#readme) - File extensions for programming languages.
72+
<br>{ } [data-languages](https://github.com/adamlui/python-utils/tree/main/data-languages/#readme) - File extensions for data languages.
73+
74+
#
75+
76+
<a href="#top">Back to top ↑</a>

prose-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.

prose-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)

prose-languages/pyproject.toml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
[build-system]
2+
requires = [
3+
"setuptools~=82.0.0",
4+
"wheel",
5+
]
6+
build-backend = "setuptools.build_meta"
7+
8+
[project]
9+
name = "prose-languages"
10+
version = "1.0.0"
11+
description = "File extensions for prose 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+
"AsciiDoc",
23+
"computer-languages",
24+
"Creole",
25+
"extensions",
26+
"file-extensions",
27+
"file‑type-detection",
28+
"filenames",
29+
"Gemini",
30+
"Gettext Catalog",
31+
"github",
32+
"language-detection",
33+
"languages",
34+
"linguist",
35+
"Markdown",
36+
"Muse",
37+
"Org",
38+
"Pod",
39+
"Pod 6",
40+
"prose-languages",
41+
"RDoc",
42+
"reStructuredText",
43+
"RMarkdown",
44+
"Sweave",
45+
"syntax-highlighting",
46+
"Texinfo",
47+
"Text",
48+
"Textile",
49+
"Vim Help File",
50+
"Wikitext",
51+
]
52+
classifiers = [
53+
"Development Status :: 5 - Production/Stable",
54+
"Intended Audience :: Developers",
55+
"Intended Audience :: Education",
56+
"Intended Audience :: Information Technology",
57+
"Intended Audience :: Science/Research",
58+
"Intended Audience :: System Administrators",
59+
"Natural Language :: English",
60+
"Operating System :: OS Independent",
61+
"Programming Language :: Python",
62+
"Programming Language :: Python :: 2",
63+
"Programming Language :: Python :: 2.6",
64+
"Programming Language :: Python :: 2.7",
65+
"Programming Language :: Python :: 3",
66+
"Programming Language :: Python :: 3.8",
67+
"Programming Language :: Python :: 3.9",
68+
"Programming Language :: Python :: 3.10",
69+
"Programming Language :: Python :: 3.11",
70+
"Programming Language :: Python :: 3.12",
71+
"Programming Language :: Python :: 3.13",
72+
"Programming Language :: Python :: 3.14",
73+
"Programming Language :: Python :: 3.15",
74+
"Topic :: Documentation",
75+
"Topic :: Education",
76+
"Topic :: Software Development",
77+
"Topic :: Software Development :: Libraries",
78+
"Topic :: Software Development :: Libraries :: Python Modules",
79+
"Topic :: Text Processing",
80+
"Topic :: Text Processing :: Linguistic",
81+
"Topic :: Utilities",
82+
]
83+
84+
[project.urls]
85+
Changelog = "https://github.com/adamlui/python-utils/releases/tag/prose-languages-1.0.0"
86+
Documentation = "https://github.com/adamlui/python-utils/tree/main/prose-languages/docs"
87+
Funding = "https://github.com/sponsors/adamlui"
88+
Homepage = "https://github.com/adamlui/python-utils/tree/main/prose-languages/#readme"
89+
Issues = "https://github.com/adamlui/python-utils/issues"
90+
"PyPI Stats" = "https://pepy.tech/projects/prose-languages"
91+
Releases = "https://github.com/adamlui/python-utils/releases"
92+
Repository = "https://github.com/adamlui/python-utils"
93+
94+
[project.optional-dependencies]
95+
dev = [
96+
"nox>=2026.2.9",
97+
"tomli~=2.4.0",
98+
"tomli-w~=1.2.0",
99+
]
100+
101+
[tool.setuptools.packages.find]
102+
where = [
103+
"src",
104+
]
105+
106+
[tool.setuptools.package-data]
107+
prose_languages = [
108+
"prose_languages.json",
109+
]

prose-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__), 'prose_languages.json')) as file:
4+
prose_languages = json.load(file)
5+
6+
sys.modules[__name__] = prose_languages
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"AsciiDoc": { "extensions": [".adoc",".asc",".asciidoc"] },
3+
"Creole": { "extensions": [".creole"] },
4+
"Gemini": { "extensions": [".gmi"] },
5+
"Gettext Catalog": { "extensions": [".po",".pot"] },
6+
"Markdown": {
7+
"extensions": [".livemd",".markdown",".md",".mdown",".mdwn",".mkd",".mkdn",".mkdown",".ronn",".scd",".workbook"]
8+
},
9+
"Muse": { "extensions": [".muse"] },
10+
"Org": { "extensions": [".org"] },
11+
"Pod": { "extensions": [".pod"] },
12+
"Pod 6": { "extensions": [".pod",".pod6"] },
13+
"RDoc": { "extensions": [".rdoc"] },
14+
"reStructuredText": { "extensions": [".rest",".rest.txt",".rst",".rst.txt"] },
15+
"RMarkdown": { "extensions": [".qmd",".rmd"] },
16+
"Sweave": { "extensions": [".rnw"] },
17+
"Texinfo": { "extensions": [".texi",".texinfo",".txi"] },
18+
"Text": { "extensions": [".fr",".nb",".ncl",".no",".txt"] },
19+
"Textile": { "extensions": [".textile"] },
20+
"Vim Help File": { "extensions": [".txt"] },
21+
"Wikitext": { "extensions": [".mediawiki",".wiki",".wikitext"] }
22+
}

0 commit comments

Comments
 (0)