module Kramdown::Converter::SyntaxHighlighter::Minted

Uses Minted to highlight code blocks and code spans.

Public Class Methods

call(converter, text, lang, type, _opts) click to toggle source
# File lib/kramdown/converter/syntax_highlighter/minted.rb, line 14
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