Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jwilm/pygments-async

Fully asynchronous Node.js wrapper for Pygments
https://github.com/jwilm/pygments-async

Last synced: 7 days ago
JSON representation

Fully asynchronous Node.js wrapper for Pygments

Awesome Lists containing this project

README

        

pygments-async
==============

Fully asynchronous wrapper for Pygments

## Usage

There are two functions exported by the package - pygmentize and pygmentizeFile.

### pygmentize

Highlight a block of code

Example:

```javascript
var pygmentize = require('pygments-async').pygmentize
, markup;

pygmentize("puts 'Hello, world!'", {lexer: 'ruby'}, function(err, out) {
// out contains pygmentized code
markup = out;
});
```

Allowed options are:

- `lexer`: Specify lexer for pygmentize
- `formatter`: Specify pygmentize lexer

Options need not be specified. If no lexer is provided pygmentize will attempt
to guess based on contents. The default formatter is `html`.

### pygmentizeFile

Load a file and pygmentize it

```javascript
var pygmentize = require('pygments-async').pygmentize
, markup;

pygmentizeFile("package.json", function(err, out) {
// out contains pygmentized package.json
markup = out;
});
```

## License

MIT

## Alternatives
- [pygments](https://github.com/pksunkara/pygments.js)