Sha256: c1fd10365735bd9647c0fa714272af4157cc20e5234552511ef729c66c7b6158

Contents?: true

Size: 910 Bytes

Versions: 17

Compression:

Stored size: 910 Bytes

Contents

# -*- coding: utf-8; frozen_string_literal: true -*-
#
#--
# Copyright (C) 2009-2019 Thomas Leitner <t_leitner@gmx.at>
#
# This file is part of kramdown which is licensed under the MIT.
#++
#

module Kramdown::Converter::SyntaxHighlighter

  # Uses Minted to highlight code blocks and code spans.
  module Minted

    def self.call(converter, text, lang, type, _opts)
      opts = converter.options[:syntax_highlighter_opts]

      # Fallback to default language
      lang ||= opts[:default_lang]

      options = []
      options << "breaklines" if opts[:wrap]
      options << "linenos" if opts[:line_numbers]
      options << "frame=#{opts[:frame]}" if opts[:frame]

      if lang && type == :block
        "\\begin{minted}[#{options.join(',')}]{#{lang}}\n#{text}\n\\end{minted}"
      elsif lang && type == :span
        "\\mintinline{#{lang}}{#{text}}"
      else
        nil
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 4 rubygems

Version Path
kramdown-2.5.1 lib/kramdown/converter/syntax_highlighter/minted.rb
kramdown-2.5.0 lib/kramdown/converter/syntax_highlighter/minted.rb
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/kramdown-2.4.0/lib/kramdown/converter/syntax_highlighter/minted.rb
kramdown-2.4.0 lib/kramdown/converter/syntax_highlighter/minted.rb
kramdown-2.3.2 lib/kramdown/converter/syntax_highlighter/minted.rb
kramdown-2.3.1 lib/kramdown/converter/syntax_highlighter/minted.rb
daqing_kramdown-2.3.2 lib/kramdown/converter/syntax_highlighter/minted.rb
daqing_kramdown-2.3.1 lib/kramdown/converter/syntax_highlighter/minted.rb
zine_brewer-1.5.0 vendor/bundle/ruby/2.7.0/gems/kramdown-2.3.0/lib/kramdown/converter/syntax_highlighter/minted.rb
zine_brewer-1.3.0 vendor/bundle/ruby/2.7.0/gems/kramdown-2.3.0/lib/kramdown/converter/syntax_highlighter/minted.rb
kramdown-2.3.0 lib/kramdown/converter/syntax_highlighter/minted.rb
kramdown-2.2.1 lib/kramdown/converter/syntax_highlighter/minted.rb
kramdown-2.2.0 lib/kramdown/converter/syntax_highlighter/minted.rb
kramdown-2.1.0 lib/kramdown/converter/syntax_highlighter/minted.rb
kramdown-2.0.0 lib/kramdown/converter/syntax_highlighter/minted.rb
kramdown-2.0.0.beta2 lib/kramdown/converter/syntax_highlighter/minted.rb
kramdown-2.0.0.beta1 lib/kramdown/converter/syntax_highlighter/minted.rb