prose-languages
v1.0.0
Published
File extensions for prose languages.
Maintainers
Readme
💻 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 700+ languages known to GitHub). Data is updated via script and released via new package version.
⚡ Installation
From your project root:
npm install prose-languages🔌 Usage
ES Modules (ESM):
import proseLangs from 'prose-languages'
mdLangData = proseLangs.Markdown
console.log(mdLangData.extensions) // => [ '.livemd', '.markdown', '.md', ... ]CommonJS (CJS):
const proseLangs = require('prose-languages')
mdLangData = proseLangs.Markdown
console.log(mdLangData.extensions) // => [ '.livemd', '.markdown', '.md', ... ]💻 Examples
Get language(s) from an extension:
function getLang(fileExt) {
const langMatches = Object.entries(proseLangs)
.filter(([_, data]) => data.extensions.includes(fileExt))
.map(([lang]) => lang)
return langMatches.length == 1 ? langMatches[0] : langMatches
}
console.log(getLang('.gmi')) // => GeminiGet language(s) from a file path:
function getLangFromPath(filepath) {
const fileExt = filepath.slice(filepath.lastIndexOf('.'))
const langMatches = Object.entries(proseLangs)
.filter(([_, data]) => data.extensions.includes(fileExt))
.map(([lang]) => lang)
return langMatches.length == 1 ? langMatches[0] : langMatches
}
console.log(getLangFromPath('document.adoc')) // => AsciiDoc
console.log(getLangFromPath('README.md')) // => Markdown
console.log(getLangFromPath('index.mdx')) // => [] (use markup-languages pkg)MIT License
Copyright © 2026 Adam Lui
📜 Related
More JavaScript utilities / Discuss / Report bug / Report vulnerability / Back to top ↑
