pygments-promise

0.0.1 • Public • Published

pygments-promise

Fully Promise wrapper for Pygments

Usage

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

pygmentize

Highlight a block of code

Example:

var pygmentize = require('pygments-async').pygmentize
  , markup;
 
pygmentize("puts 'Hello, world!'", {lexer: 'ruby'}).then(function(out) {
  // out contains pygmentized code
  markup = out;
});

Allowed options are:

  • lexer: Specify lexer for pygmentize
  • formatter: Specify pygmentize lexer
  • options: A object of options passed to pygmentize via -P key=value

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

var pygmentizeFile = require('pygments-async').pygmentizeFile
  , markup;
 
pygmentizeFile("package.json").then(function(out) {
  // out contains pygmentized package.json
  markup = out;
});

License

MIT

Alternatives

Readme

Keywords

Package Sidebar

Install

npm i pygments-promise

Weekly Downloads

0

Version

0.0.1

License

MIT

Unpacked Size

12 kB

Total Files

9

Last publish

Collaborators

  • menci