https://github.com/rafaelrinaldi/guess-programming-language
Naive programming language guessing built on top of highlight.js
https://github.com/rafaelrinaldi/guess-programming-language
guess highlight-js programming-language
Last synced: 3 months ago
JSON representation
Naive programming language guessing built on top of highlight.js
- Host: GitHub
- URL: https://github.com/rafaelrinaldi/guess-programming-language
- Owner: rafaelrinaldi
- Created: 2018-08-08T15:11:33.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-02T18:56:10.000Z (over 5 years ago)
- Last Synced: 2025-07-04T20:44:57.505Z (3 months ago)
- Topics: guess, highlight-js, programming-language
- Language: JavaScript
- Homepage:
- Size: 104 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# guess-programming-language [](https://semaphoreci.com/rafaelrinaldi/guess-programming-language)
> Naive programming language guessing built on top of [highlight.js][highlight.js]
[highlight.js]: https://github.com/highlightjs/highlight.js
## Install
```sh
npm i guess-programming-language
```## Usage
```js
import guessProgrammingLanguage from 'guess-programming-language'async function run() {
console.log(
await guessProgrammingLanguage('const foo = "bar";')
) //=> javascript
}run()
```## API
### `guessProgrammingLanguage(value)`
Returns a `Promise` instance that resolves to the programming language name (lower case) if a match is found or `null` if no match is found.
#### `value`
Type: `String`
Value for the programming language to guess.
## Why
- [highlight.js][highlight.js] is great and its guessing mechanism is good enough for most cases I needed it for
- Most libraries I've tried either have confusing APIs or require Node.js C bindings that fails to build when npm installing it## Gotchas
- If you're looking for something super precise this is not it
- This library currently only works in Node.js, feel free to send a PR if you want to add browser support## License
MIT © [Rafael Rinaldi](https://rinaldi.io)
---