pygmentize-bundled
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -94,4 +94,11 @@ var spawn = require('child_process').spawn | ||
] | ||
, exec = spawn("python", [path.join(__dirname, 'vendor/pygments/pygmentize')].concat(execArgs)) | ||
if (options.options) { | ||
for (var option in options.options) { | ||
execArgs.push('-P', option + '=' + options.options[option]) | ||
} | ||
} | ||
var exec = spawn("python", [path.join(__dirname, 'vendor/pygments/pygmentize')].concat(execArgs)) | ||
return typeof code == 'string' && typeof callback == 'function' | ||
@@ -98,0 +105,0 @@ ? fromString(exec, code, callback) |
{ | ||
"name": "pygmentize-bundled" | ||
, "version": "1.1.0" | ||
, "version": "1.2.0" | ||
, "description": "A simple wrapper around Python's Pygments code formatter, with Pygments bundled" | ||
@@ -24,2 +24,3 @@ , "main": "index.js" | ||
, "Ahmed Fasih (https://github.com/fasiha)" | ||
, "Scott Walkinshaw (https://github.com/swalkinshaw)" | ||
] | ||
@@ -26,0 +27,0 @@ , "license": "MIT" |
@@ -14,3 +14,3 @@ # Pygmentize (Bundled) | ||
* `options` contains options to be passed to Pygments. Currently only `"lang"` and `"format"` are supported. | ||
* `options` contains options to be passed to Pygments (see [Options](#options)). | ||
* `code` is a String to be formatted. | ||
@@ -23,5 +23,14 @@ * `callback` is a Function, called when complete. The first argument will be an `error` object/string if there was a problem and the second argument will be a Buffer containing your formatted code. | ||
* `options` contains options to be passed to Pygments. Currently only `"lang"` and `"format"` are supported. | ||
* `options` contains options to be passed to Pygments (see [Options](#options)). | ||
## Options | ||
Language/lexer, formatter, and their options are currently supported. Filters are not supported yet. | ||
* `lang`: source language/lexer name - `string` | ||
* `format`: output formatter name - `string` | ||
* `options`: lexer and formatter options - `object` | ||
## Examples | ||
@@ -34,3 +43,3 @@ | ||
pygmentize({ lang: 'js', format: 'html'}, 'var a = "b";', function (err, result) { | ||
pygmentize({ lang: 'js', format: 'html' }, 'var a = "b";', function (err, result) { | ||
console.log(result.toString()) | ||
@@ -52,2 +61,12 @@ }) | ||
Example with extra options: | ||
```js | ||
var pygmentize = require('pygmentize-bundled') | ||
pygmentize({ lang: 'php', format: 'html', options: { startinline: 1 } }, 'var a = true;', function (err, result) { | ||
console.log(result.toString()) | ||
}) | ||
``` | ||
A streaming API is also available. Simply omit the `code` and `callback` arguments: | ||
@@ -71,2 +90,3 @@ | ||
* [Ahmed Fasih](https://github.com/fasiha) | ||
* [Scott Walkinshaw](https://github.com/swalkinshaw) | ||
@@ -77,2 +97,2 @@ ## Licence & copyright | ||
Pygments is licenced under the BSD licence. | ||
Pygments is licenced under the BSD licence. |
@@ -20,6 +20,19 @@ var assert = require('assert') | ||
} | ||
, { | ||
lang: 'php' | ||
, format: 'html' | ||
, input: 'var a = true;' | ||
, output: '<div class="highlight"><pre><span class="x">var a = true;</span></pre></div>' | ||
} | ||
, { | ||
lang: 'php' | ||
, format: 'html' | ||
, options: { startinline: 1 } | ||
, input: 'var a = true;' | ||
, output: '<div class="highlight"><pre><span class="k">var</span> <span class="nx">a</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span></pre></div>' | ||
} | ||
] | ||
cases.forEach(function (c) { | ||
pygments({ lang: c.lang, format: c.format }, c.input, function (err, result) { | ||
pygments({ lang: c.lang, format: c.format, options: c.options || {} }, c.input, function (err, result) { | ||
assert.equal(err, null) | ||
@@ -26,0 +39,0 @@ result = result.toString().replace(/\n/g, '') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4796679
489
93