Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
pygmentize-bundled
Advanced tools
A simple wrapper around Python's Pygments code formatter, with Pygments bundled
A simple wrapper around Python's Pygments code formatter, with Pygments bundled.
Available as a simple String-in, Buffer-out interface and also as a read/write-Stream interface.
pygmentize(options, code, callback)
Pygmentize a given code
string and return it as a Buffer to the callback
Function.
options
contains options to be passed to Pygments (see Options).code
is a String to be formatted.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.pygmentize(options)
When you only supply the options
argument, it will return a read/write Stream that you can pipe to and from to format your code.
options
contains options to be passed to Pygments (see 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
The string interface is very simple:
var pygmentize = require('pygmentize-bundled')
pygmentize({ lang: 'js', format: 'html' }, 'var a = "b";', function (err, result) {
console.log(result.toString())
})
Results in:
<div class="highlight"><pre>
<span class="kd">var</span>
<span class="nx">a</span>
<span class="o">=</span>
<span class="s2">"b"</span>
<span class="p">;</span>
</pre></div>
Example with extra options:
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:
var pygmentize = require('pygmentize-bundled')
process.stdin.pipe(
pygmentize({ lang: 'js', format: 'html' })
).pipe(process.stdout);
Refer to the Pygments documentation. For supported languages, see the list of lexers, for supported formatted, see the list of formatters.
Pygments (Bundled) is Copyright (c) 2012 Rod Vagg <@rvagg> and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details.
Pygments is licenced under the BSD licence.
FAQs
A simple wrapper around Python's Pygments code formatter, with Pygments bundled
The npm package pygmentize-bundled receives a total of 4,121 weekly downloads. As such, pygmentize-bundled popularity was classified as popular.
We found that pygmentize-bundled demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.