Sha256: fa603058baec670d4643df43512ffd5a69441a0a67df043ff6d974c445e79b1c
Contents?: true
Size: 1.06 KB
Versions: 42
Compression:
Stored size: 1.06 KB
Contents
# frozen_string_literal: true require 'kramdown' module Thredded module HtmlPipeline class KramdownFilter < ::HTML::Pipeline::TextFilter class << self attr_accessor :options end # See http://kramdown.gettalong.org/options.html self.options = { input: 'GFM', gfm_quirks: 'paragraph_end', # Smart quotes conflict with @"at mentions". Disable smart quotes. smart_quotes: %w[apos apos quot quot], remove_block_html_tags: false, syntax_highlighter: nil } def initialize(text, context = nil, result = nil) super text, context, result if @text.frozen? @text = @text.delete("\r") else @text.delete! "\r" end end # Convert Markdown to HTML using the best available implementation # and convert into a DocumentFragment. def call result = Kramdown::Document.new(@text, self.class.options.deep_merge(context[:kramdown_options] || {})).to_html result.rstrip! result end end end end
Version data entries
42 entries across 42 versions & 2 rubygems