class HTMLPipeline::ConvertFilter::MarkdownFilter

HTML Filter that converts Markdown text into HTML.

Context options:

:markdown[:parse] => Commonmarker parse options
:markdown[:render] => Commonmarker render options
:markdown[:extensions] => Commonmarker extensions options

Public Class Methods

new(context: {}, result: {}) click to toggle source
Calls superclass method HTMLPipeline::ConvertFilter::new
# File lib/html_pipeline/convert_filter/markdown_filter.rb, line 14
def initialize(context: {}, result: {})
  super
end

Public Instance Methods

call(text, context: @context) click to toggle source

Convert Commonmark to HTML using the best available implementation.

# File lib/html_pipeline/convert_filter/markdown_filter.rb, line 19
def call(text, context: @context)
  options = context.fetch(:markdown, {})
  plugins = options.fetch(:plugins, {})
  Commonmarker.to_html(text, options: options, plugins: plugins).rstrip!
end