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

      check_availability('highlight', '--version')

      # Build command
      cmd = [ 'highlight', '--syntax', language, '--fragment' ]
      params.each do |key, value|
        if SIMON_HIGHLIGHT_OPT_MAP[key]
          cmd << SIMON_HIGHLIGHT_OPT_MAP[key]
        else
          # TODO allow passing other options
          case key
          when :style
            cmd << '--style' << params[:style]
          end
        end
      end

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

      # Get result
      stdout.rewind
      stdout.read
    end
# Runs the content through [Highlight](http://www.andre-simon.de/doku/highlight/en/highlight.html).
#
# @api private
#
# @since 3.2.0
#
# @param [String] code The code to colorize
#
# @param [String] language The language the code is written in
#
# @option params [String] :style The style to use
#
# @return [String] The colorized output
Runs the content through [Highlight].
Runs the content through [ Highlight ] .
def simon_highlight(code, language, params={})
      require 'systemu'
      check_availability('highlight', '--version')
      cmd = [ 'highlight', '--syntax', language, '--fragment' ]
      params.each do |key, value|
        if SIMON_HIGHLIGHT_OPT_MAP[key]
          cmd << SIMON_HIGHLIGHT_OPT_MAP[key]
        else
          case key
          when :style
            cmd << '--style' << params[:style]
          end
        end
      end
      stdout = StringIO.new
      systemu cmd, 'stdin' => code, 'stdout' => stdout
      stdout.rewind
      stdout.read
    end
def simon_highlight ( code , language , params = { } ) require 'systemu' check_availability ( 'highlight' , '--version' ) cmd = [ 'highlight' , '--syntax' , language , '--fragment' ] params . each do | key , value | if SIMON_HIGHLIGHT_OPT_MAP [ key ] cmd << SIMON_HIGHLIGHT_OPT_MAP [ key ] else case key when :style cmd << '--style' << params [ :style ] end end end stdout = StringIO . new systemu cmd , 'stdin' => code , 'stdout' => stdout stdout . rewind stdout . read end
Runs the content through [Highlight](http://www.andre-simon.de/doku/highlight/en/highlight.html).
Runs the content through [ Highlight ] ( http : // www . andre - simon . de / doku / highlight / en / highlight . html ) .
# Build command # TODO allow passing other options # Run command # Get result
The colorized output
The colorized output
String
code
language
params
:style The style to use
: style The style to use
language The language the code is written in
language The language the code is written in
api
None
since
None