Class: Jekyll::Converters::Markdown

Inherits:
Jekyll::Converter show all
Defined in:
lib/jekyll/converters/markdown.rb,
lib/jekyll/converters/markdown/maruku_parser.rb,
lib/jekyll/converters/markdown/kramdown_parser.rb,
lib/jekyll/converters/markdown/rdiscount_parser.rb,
lib/jekyll/converters/markdown/redcarpet_parser.rb

Defined Under Namespace

Classes: KramdownParser, MarukuParser, RDiscountParser, RedcarpetParser

Constant Summary

Constants inherited from Plugin

Plugin::PRIORITIES

Instance Method Summary collapse

Methods inherited from Jekyll::Converter

highlighter_prefix, #highlighter_prefix, highlighter_suffix, #highlighter_suffix, #initialize

Methods inherited from Plugin

<=>, #<=>, descendants, #initialize, priority, safe

Constructor Details

This class inherits a constructor from Jekyll::Converter

Instance Method Details

#convert(content) ⇒ Object


61
62
63
64
# File 'lib/jekyll/converters/markdown.rb', line 61

def convert(content)
  setup
  @parser.convert(content)
end

#extname_listObject


49
50
51
# File 'lib/jekyll/converters/markdown.rb', line 49

def extname_list
  @extname_list ||= @config['markdown_ext'].split(',').map { |e| ".#{e.downcase}" }
end

#matches(ext) ⇒ Object


53
54
55
# File 'lib/jekyll/converters/markdown.rb', line 53

def matches(ext)
  extname_list.include? ext.downcase
end

#output_ext(ext) ⇒ Object


57
58
59
# File 'lib/jekyll/converters/markdown.rb', line 57

def output_ext(ext)
  ".html"
end

#setupObject


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jekyll/converters/markdown.rb', line 9

def setup
  return if @setup
  @parser =
    case @config['markdown'].downcase
      when 'redcarpet' then RedcarpetParser.new(@config)
      when 'kramdown'  then KramdownParser.new(@config)
      when 'rdiscount' then RDiscountParser.new(@config)
      when 'maruku'    then MarukuParser.new(@config)
    else
      # So they can't try some tricky bullshit or go down the ancestor chain, I hope.
      if allowed_custom_class?(@config['markdown'])
        self.class.const_get(@config['markdown']).new(@config)
      else
        Jekyll.logger.error "Invalid Markdown Processor:", "#{@config['markdown']}"
        Jekyll.logger.error "", "Valid options are [ #{valid_processors.join(" | ")} ]"
        raise Errors::FatalException, "Invalid Markdown Processor: #{@config['markdown']}"
      end
    end
  @setup = true
end

#third_party_processorsObject


39
40
41
42
43
44
45
46
47
# File 'lib/jekyll/converters/markdown.rb', line 39

def third_party_processors
  self.class.constants - %w[
    KramdownParser
    MarukuParser
    RDiscountParser
    RedcarpetParser
    PRIORITIES
  ].map(&:to_sym)
end

#valid_processorsObject


30
31
32
33
34
35
36
37
# File 'lib/jekyll/converters/markdown.rb', line 30

def valid_processors
  %w[
    maruku
    rdiscount
    kramdown
    redcarpet
  ] + third_party_processors
end