Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/microgit-com/linguist.cr
Github's Linguist but in Crystal
https://github.com/microgit-com/linguist.cr
crystal linguistic syntax-highlighting
Last synced: 3 months ago
JSON representation
Github's Linguist but in Crystal
- Host: GitHub
- URL: https://github.com/microgit-com/linguist.cr
- Owner: microgit-com
- License: mit
- Created: 2020-02-15T09:16:27.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-05-31T05:46:26.000Z (over 4 years ago)
- Last Synced: 2024-05-06T00:04:57.451Z (6 months ago)
- Topics: crystal, linguistic, syntax-highlighting
- Language: Crystal
- Size: 5.89 MB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-crystal - linguist.cr - Using multiple ways to find programming language used in files, based on Github's Linguist (Code Analysis and Metrics)
README
# linguist.cr
Github's linguist but in crystal.
Linguist will use different ways to find what type of programming language every file is, which can be used for stats or for highlights.
We only have filename, extension name and classifier mapping now but support languages.yml-format and samples format from Github's linguist. Hopefully soon we will add the rest, like Heuristics and shebang filtering support.
We can not promise that the loaded data in `./data` is up to date. So if you want to be sure, let's train it again with overwrite set to `true`.
## Installation
1. Add the dependency to your `shard.yml`:
```yaml
dependencies:
linguist.cr:
github: microgit-com/linguist.cr
```2. Run `shards install`
## Usage
```crystal
require "linguist"
```Set path to the languages.yml if it is not working like this:
```crystal
Linguist.configure do |settings|
settings.path = "./config/linguist/languages.yml"
end
```The languages.yml can be found in the git repo of this or a more up to date one on github's linguist repo at https://github.com/github/linguist
### Using repository
```crystal
repo = Git::Repository.open("./")
linguist = Linguist::Linguist.new
linguist.with_repo(repo, repo.head.target_id)logger = Logger.new(STDOUT)
langs = linguist.languages
logger.info langs
```## Development
We have this todo:
- [x] Repository blob support
- [x] Classifier
- [x] Filename-finder
- [x] Extension-finder
- [ ] Heuristics support
- [ ] Shebang filter support
- [ ] simple file text check without repository.## Contributing
1. Fork it ()
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Contributors
- [Håkan Nylén](https://github.com/confact) - creator and maintainer