Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pygmentize-bundled

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pygmentize-bundled

A simple wrapper around Python's Pygments code formatter, with Pygments bundled

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.9K
decreased by-42.83%
Maintainers
1
Weekly downloads
 
Created
Source

Pygmentize (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.

API

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. Currently only "lang" and "format" are supported.
  • 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. Currently only "lang" and "format" are supported.

Examples

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">&quot;b&quot;</span>
  <span class="p">;</span>
</pre></div>

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.

Contributors

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.

Keywords

FAQs

Package last updated on 19 Oct 2012

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc