Sha256: 1b9472a068c7616cc6393a4579205bb6f23233b87ffd86b405104b97931b405a
Contents?: true
Size: 940 Bytes
Versions: 7
Compression:
Stored size: 940 Bytes
Contents
# -*- coding: utf-8 -*- # #-- # Copyright (C) 2009-2015 Thomas Leitner <t_leitner@gmx.at> # # This file is part of kramdown which is licensed under the MIT. #++ # module Kramdown::Converter::SyntaxHighlighter # Uses Rouge which is CSS-compatible to Pygments to highlight code blocks and code spans. module Rouge begin require 'rouge' # Highlighting via Rouge is available if this constant is +true+. AVAILABLE = true rescue LoadError, SyntaxError AVAILABLE = false # :nodoc: end def self.call(converter, text, lang, type, _unused_opts) opts = converter.options[:syntax_highlighter_opts].dup lexer = ::Rouge::Lexer.find_fancy(lang || opts[:default_lang], text) return nil unless lexer opts[:wrap] = false if type == :span formatter = (opts.delete(:formatter) || ::Rouge::Formatters::HTML).new(opts) formatter.format(lexer.lex(text)) end end end
Version data entries
7 entries across 7 versions & 3 rubygems