class Jekyll::Converters::Markdown
For more info on converters see jekyllrb.com/docs/plugins/converters/
Markdown converter.
def convert(content)
content - String content of file (without front matter).
Logic to do the content conversion.
def convert(content) setup @cache.getset(content) do @parser.convert(content) end end
def custom_class_allowed?(parser_name)
Returns true if the parser name contains only alphanumeric characters and is defined
parser_name - the name of the parser class
markdown class name.
Private: Determine whether a class name is an allowed custom
def custom_class_allowed?(parser_name) parser_name !~ %r![^A-Za-z0-9_]! && self.class.constants.include?(parser_name.to_sym) end
def custom_processor
def custom_processor converter_name = @config["markdown"] self.class.const_get(converter_name).new(@config) if custom_class_allowed?(converter_name) end
def extname_list
def extname_list @extname_list ||= @config["markdown_ext"].split(",").map! { |e| ".#{e.downcase}" } end
def get_processor
To ensure compatibility, this check has been disabled on this method
RuboCop does not allow reader methods to have names starting with `get_`
def get_processor case @config["markdown"].downcase when "kramdown" then KramdownParser.new(@config) else custom_processor end end
def matches(ext)
ext - The String extension to check.
Takes one argument: the file's extension (including the dot).
Does the given extension match this converter's list of acceptable extensions?
def matches(ext) extname_list.include?(ext.downcase) end
def output_ext(_ext)
ext - The String extension or original file.
Public: The extension to be given to the output file (including the dot).
def output_ext(_ext) ".html" end
def setup
def setup return if @setup ||= false unless (@parser = get_processor) if @config["safe"] Jekyll.logger.warn "Build Warning:", "Custom processors are not loaded in safe mode" end Jekyll.logger.error "Markdown processor:", "#{@config["markdown"].inspect} is not a valid Markdown processor." Jekyll.logger.error "", "Available processors are: #{valid_processors.join(", ")}" Jekyll.logger.error "" raise Errors::FatalException, "Invalid Markdown processor given: #{@config["markdown"]}" end @cache = Jekyll::Cache.new("Jekyll::Converters::Markdown") @setup = true end
def third_party_processors
Public: A list of processors that you provide via plugins.
def third_party_processors self.class.constants - [:KramdownParser, :PRIORITIES] end
def valid_processors
and the ones that you have provided to us (if they're whitelisted for use in safe mode).
Public: Provides you with a list of processors comprised of the ones we support internally
def valid_processors [:kramdown] + third_party_processors end