0.2.1 • Published 9 years ago
pygments v0.2.1
Pygments
A pygments wrapper for node.js
Installation
Installing npm (node package manager)
curl http://npmjs.org/install.sh | shInstalling pygments
[sudo] npm install pygmentsUsage
colorize(target, lexer, format, callback, options);
- Default lexer is
js - Default format is
html
Highlight code
var highlight = require('pygments').colorize;
highlight('puts "Hello World"', 'ruby', 'console', function(data) {
console.log(data);
});Highlight a file
var highlight = require('pygments').colorize;
highlight('/home/pkumar/package.json', null, 'html', function(data) {
console.log(data);
});If you want to highlight string /home/pkumar/package.json itself,
var highlight = require('pygments').colorize;
highlight('/home/pkumar/package.json', null, 'html', function(data) {
console.log(data);
}, {'force': true});Run Tests
All of the pygments tests are written in vows, and cover all of the use cases described above.
npm testLicense
See LICENSE for details.
Contact
Pavan Kumar Sunkara