Class: Jekyll::Converters::Markdown
- Inherits:
-
Jekyll::Converter
- Object
- Plugin
- Jekyll::Converter
- Jekyll::Converters::Markdown
- Defined in:
- lib/jekyll/converters/markdown.rb,
lib/jekyll/converters/markdown/kramdown_parser.rb,
lib/jekyll/converters/markdown/rdiscount_parser.rb
Defined Under Namespace
Classes: KramdownParser, RDiscountParser, RedcarpetParser
Constant Summary
Constants inherited from Plugin
Instance Method Summary collapse
- #convert(content) ⇒ Object
- #extname_list ⇒ Object
-
#get_processor ⇒ Object
Rubocop does not allow reader methods to have names starting with ‘get_` To ensure compatibility, this check has been disabled on this method.
- #matches(ext) ⇒ Object
- #output_ext(_ext) ⇒ Object
- #setup ⇒ Object
-
#third_party_processors ⇒ Object
Public: A list of processors that you provide via plugins.
-
#valid_processors ⇒ Object
Public: Provides you with a list of processors, the ones we support internally and the ones that you have provided to us (if you are not in safe mode.).
Methods inherited from Jekyll::Converter
highlighter_prefix, #highlighter_prefix, highlighter_suffix, #highlighter_suffix, #initialize
Methods inherited from Plugin
#<=>, <=>, catch_inheritance, descendants, inherited, #initialize, priority, safe
Constructor Details
This class inherits a constructor from Jekyll::Converter
Instance Method Details
#convert(content) ⇒ Object
75 76 77 78 |
# File 'lib/jekyll/converters/markdown.rb', line 75 def convert(content) setup @parser.convert(content) end |
#extname_list ⇒ Object
61 62 63 64 65 |
# File 'lib/jekyll/converters/markdown.rb', line 61 def extname_list @extname_list ||= @config["markdown_ext"].split(",").map do |e| ".#{e.downcase}" end end |
#get_processor ⇒ Object
Rubocop does not allow reader methods to have names starting with ‘get_` To ensure compatibility, this check has been disabled on this method
rubocop:disable Naming/AccessorMethodName
31 32 33 34 35 36 37 38 39 |
# File 'lib/jekyll/converters/markdown.rb', line 31 def get_processor case @config["markdown"].downcase when "redcarpet" then return RedcarpetParser.new(@config) when "kramdown" then return KramdownParser.new(@config) when "rdiscount" then return RDiscountParser.new(@config) else custom_processor end end |
#matches(ext) ⇒ Object
67 68 69 |
# File 'lib/jekyll/converters/markdown.rb', line 67 def matches(ext) extname_list.include?(ext.downcase) end |
#output_ext(_ext) ⇒ Object
71 72 73 |
# File 'lib/jekyll/converters/markdown.rb', line 71 def output_ext(_ext) ".html" end |
#setup ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/jekyll/converters/markdown.rb', line 10 def setup return if @setup ||= false unless (@parser = get_processor) Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"] if @config["safe"] Jekyll.logger.info "", "Custom processors are not loaded in safe mode" end Jekyll.logger.error( "", "Available processors are: #{valid_processors.join(", ")}" ) raise Errors::FatalException, "Bailing out; invalid Markdown processor." end @setup = true end |
#third_party_processors ⇒ Object
Public: A list of processors that you provide via plugins. This is really only available if you are not in safe mode, if you are in safe mode (re: GitHub) then there will be none.
54 55 56 57 58 59 |
# File 'lib/jekyll/converters/markdown.rb', line 54 def third_party_processors self.class.constants - \ %w(KramdownParser RDiscountParser RedcarpetParser PRIORITIES).map( &:to_sym ) end |
#valid_processors ⇒ Object
Public: Provides you with a list of processors, the ones we support internally and the ones that you have provided to us (if you are not in safe mode.)
46 47 48 |
# File 'lib/jekyll/converters/markdown.rb', line 46 def valid_processors %w(rdiscount kramdown redcarpet) + third_party_processors end |