Sha256: 87a67a62fde0abe2a51b20b42e4e087c796ff2a1b52af2e9000b992032aecb4d

Contents?: true

Size: 645 Bytes

Versions: 1

Compression:

Stored size: 645 Bytes

Contents

require 'html/pipeline'
require 'magnet/markdown'
require 'magnet/markdown/filter'

class Magnet::Markdown::Processor
  DEFAULT_CONTEXT = {
    emoji_root: '/images'
  }.freeze

  DEFAULT_FILTERS = [
    Magnet::Markdown::Filter::Markdown,
    Magnet::Markdown::Filter::Sanitize,
    HTML::Pipeline::ImageMaxWidthFilter,
    Magnet::Markdown::Filter::Emoji
  ].freeze

  def initialize(context = nil)
    context ||= {}
    @context = DEFAULT_CONTEXT.merge(context)
  end

  def call(input, context = nil)
    HTML::Pipeline.new(filters, @context).call(input, context || {})
  end

  def filters
    @filters ||= DEFAULT_FILTERS.clone
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
magnet-markdown-0.0.1 lib/magnet/markdown/processor.rb