lib/nanoc/filters/colorize_syntax.rb
def pygmentize(code, language, params={})
      require 'systemu'
      check_availability('pygmentize', '-V')

      params[:encoding] ||= 'utf-8'
      params[:nowrap]   ||= 'True'

      # Build command
      cmd = [ 'pygmentize', '-l', language, '-f', 'html' ]
      cmd << '-O' << params.map { |k,v| "#{k}=#{v}" }.join(',') unless params.empty?

      # Run command
      stdout = StringIO.new
      systemu cmd, 'stdin' => code, 'stdout' => stdout

      # Get result
      stdout.rewind
      stdout.read
    end
# Runs the content through [pygmentize](http://pygments.org/docs/cmdline/),
# the commandline frontend for [Pygments](http://pygments.org/).
#
# @api private
#
# @param [String] code The code to colorize
#
# @param [String] language The language the code is written in
#
# @option params [String, Symbol] :encoding The encoding of the code block
#
# @return [String] The colorized output
Runs the content through [pygmentize],
the commandline frontend for [Pygments].
Runs the content through [ pygmentize ] the commandline frontend for [ Pygments ] .
def pygmentize(code, language, params={})
      require 'systemu'
      check_availability('pygmentize', '-V')
      params[:encoding] ||= 'utf-8'
      params[:nowrap]   ||= 'True'
      cmd = [ 'pygmentize', '-l', language, '-f', 'html' ]
      cmd << '-O' << params.map { |k,v| "#{k}=#{v}" }.join(',') unless params.empty?
      stdout = StringIO.new
      systemu cmd, 'stdin' => code, 'stdout' => stdout
      stdout.rewind
      stdout.read
    end
def pygmentize ( code , language , params = { } ) require 'systemu' check_availability ( 'pygmentize' , '-V' ) params [ :encoding ] ||= 'utf-8' params [ :nowrap ] ||= 'True' cmd = [ 'pygmentize' , '-l' , language , '-f' , 'html' ] cmd << '-O' << params . map { | k , v | "#{k}=#{v}" } . join ( ',' ) unless params . empty? stdout = StringIO . new systemu cmd , 'stdin' => code , 'stdout' => stdout stdout . rewind stdout . read end
Runs the content through [pygmentize](http://pygments.org/docs/cmdline/),
the commandline frontend for [Pygments](http://pygments.org/).
Runs the content through [ pygmentize ] ( http : // pygments . org / docs / cmdline / ) the commandline frontend for [ Pygments ] ( http : // pygments . org / ) .
# Build command # Run command # Get result
The colorized output
The colorized output
String
code
language
params
:encoding The encoding of the code block
: encoding The encoding of the code block
language The language the code is written in
language The language the code is written in
api
None