Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atom/highlights
Syntax highlighter
https://github.com/atom/highlights
Last synced: 6 days ago
JSON representation
Syntax highlighter
- Host: GitHub
- URL: https://github.com/atom/highlights
- Owner: atom
- License: mit
- Archived: true
- Created: 2014-03-18T21:46:28.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-09-28T10:52:01.000Z (about 2 years ago)
- Last Synced: 2024-04-08T16:24:42.920Z (7 months ago)
- Language: CoffeeScript
- Homepage: https://atom.github.io/highlights
- Size: 524 KB
- Stars: 531
- Watchers: 20
- Forks: 66
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
##### Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our [official announcement](https://github.blog/2022-06-08-sunsetting-atom/)
![](https://f.cloud.github.com/assets/671378/2454103/24d89962-aee6-11e3-9dcf-ee2d81ec0373.jpg)Reads in code, writes out HTML with CSS classes based on the tokens in the code.
[![CI](https://github.com/atom/highlights/actions/workflows/ci.yml/badge.svg)](https://github.com/atom/highlights/actions/workflows/ci.yml)
See it in action [here](https://atom.github.io/highlights/examples).
### Installing
```sh
npm install highlights
```### Using
Run `highlights -h` for full details about the supported options.
To convert a source file to tokenized HTML run the following:
```sh
highlights file.coffee -o file.html
```Now you have a `file.html` file that has a big `
` tag with a `` for
each line with `` elements for each token.Then you can compile an existing Atom theme into a stylesheet with the
following:```sh
git clone https://github.com/atom/atom-dark-syntax
cd atom-dark-syntax
npm install -g less
lessc --include-path=styles index.less atom-dark-syntax.css
```Now you have an `atom-dark-syntax.css` stylesheet that be combined with
the `file.html` file to generate some nice looking code.Check out the [examples](https://atom.github.io/highlights/examples) to see
it in action.Check out [atom.io](https://atom.io/packages) to find more themes.
Some popular themes:
* [atom-dark-syntax](https://github.com/atom/atom-dark-syntax)
* [atom-light-syntax](https://github.com/atom/atom-light-syntax)
* [solarized-dark-syntax](https://github.com/atom/solarized-dark-syntax)
* [solarized-light-syntax](https://github.com/atom/solarized-light-syntax)#### Using in code
```coffee
Highlights = require 'highlights'
highlighter = new Highlights()
html = highlighter.highlightSync
fileContents: 'var hello = "world";'
scopeName: 'source.js'console.log html
```Outputs:
```html
var
hello
=
"
world
"
;
```### Loading Grammars From Modules
highlights exposes the method `requireGrammarsSync`, for loading grammars from
npm modules. The usage is as follows:```bash
npm install atom-language-clojure
``````coffee
Highlights = require 'highlights'
highlighter = new Highlights()
highlighter.requireGrammarsSync
modulePath: require.resolve('atom-language-clojure/package.json')
```### Developing
* Clone this repository `git clone https://github.com/atom/highlights`
* Update the submodules by running `git submodule update --init --recursive`
* Run `npm install` to install the dependencies, compile the CoffeeScript, and
build the grammars
* Run `npm test` to run the specs:green_heart: Pull requests are greatly appreciated and welcomed.