jimjh/genie-parser

View on GitHub
lib/spirit/render/processors/pygments_processor.rb

Summary

Maintainability
A
0 mins
Test Coverage
require 'pygments'
module Spirit
  module Render
    module Processors

      class PygmentsProcessor < Base

        process :block_code, :highlight_code

        # Pygmentizes code blocks.
        # @param [String] code        code block contents
        # @param [String] marker      name of language
        # @return [String] highlighted code
        def highlight_code(code, marker)
          Pygments.highlight(code, lexer: marker || 'text')
        end

      end

    end
  end
end