Sha256: 37eb2ccd9fcad5e7da6d50da107f45d96fb09107cfbcca345616aa70d21e58c7
Contents?: true
Size: 1.21 KB
Versions: 13
Compression:
Stored size: 1.21 KB
Contents
# encoding: utf-8 require 'kramdown' # External module Kramdown # External module Converter # External module SyntaxHighlighter # Middleman Presentation Converter module MiddlemanPresentation def self.call(converter, text, lang, type, _unused_opts) opts = converter.options[:syntax_highlighter_opts].dup text = ERB::Util.html_escape(text) case type when :span %(<code class=\"#{opts[:inline_code_class]}\">#{text}</code>) when :block %(<pre class=\"#{opts[:code_block_class]}\"><code class=\"#{opts[:language_prefix]}#{lang}\">#{text}</code></pre>) else %(<pre class=\"#{opts[:code_block_class]}\"><code class=\"#{opts[:language_prefix]}#{lang}\">#{text}</code></pre>) end end end end end end # External module Kramdown # External module Converter klass = ::Kramdown::Converter::SyntaxHighlighter::MiddlemanPresentation kn_down = :middleman_presentation add_syntax_highlighter(kn_down) do |converter, text, lang, type, opts| add_syntax_highlighter(kn_down, klass) syntax_highlighter(kn_down).call(converter, text, lang, type, opts) end end end
Version data entries
13 entries across 13 versions & 1 rubygems