Class: Bunto::Converters::Markdown
- Inherits:
-
Bunto::Converter
- Object
- Plugin
- Bunto::Converter
- Bunto::Converters::Markdown
- Defined in:
- lib/bunto/converters/markdown.rb,
lib/bunto/converters/markdown/kramdown_parser.rb,
lib/bunto/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 Bunto::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 Bunto::Converter
Instance Method Details
#convert(content) ⇒ Object
73 74 75 76 |
# File 'lib/bunto/converters/markdown.rb', line 73 def convert(content) setup @parser.convert(content) end |
#extname_list ⇒ Object
59 60 61 62 63 |
# File 'lib/bunto/converters/markdown.rb', line 59 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 Style/AccessorMethodName
29 30 31 32 33 34 35 36 37 |
# File 'lib/bunto/converters/markdown.rb', line 29 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
65 66 67 |
# File 'lib/bunto/converters/markdown.rb', line 65 def matches(ext) extname_list.include?(ext.downcase) end |
#output_ext(_ext) ⇒ Object
69 70 71 |
# File 'lib/bunto/converters/markdown.rb', line 69 def output_ext(_ext) ".html" end |
#setup ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/bunto/converters/markdown.rb', line 8 def setup return if @setup ||= false unless (@parser = get_processor) Bunto.logger.error "Invalid Markdown processor given:", @config["markdown"] if @config["safe"] Bunto.logger.info "", "Custom processors are not loaded in safe mode" end Bunto.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.
52 53 54 55 56 57 |
# File 'lib/bunto/converters/markdown.rb', line 52 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.)
44 45 46 |
# File 'lib/bunto/converters/markdown.rb', line 44 def valid_processors %W(rdiscount kramdown redcarpet) + third_party_processors end |