Class: Redmine::WikiFormatting::CommonMark::MarkdownFilter

Inherits:
HTML::Pipeline::TextFilter
  • Object
show all
Defined in:
lib/redmine/wiki_formatting/common_mark/markdown_filter.rb

Overview

Converts Markdown to HTML using CommonMarker

We do not use the stock HTML::Pipeline::MarkdownFilter because this does not allow for straightforward configuration of render and parsing options

Instance Method Summary collapse

Constructor Details

#initialize(text, context = nil, result = nil) ⇒ MarkdownFilter

Returns a new instance of MarkdownFilter.



29
30
31
32
# File 'lib/redmine/wiki_formatting/common_mark/markdown_filter.rb', line 29

def initialize(text, context = nil, result = nil)
  super text, context, result
  @text = @text.delete "\r"
end

Instance Method Details

#callObject



34
35
36
37
38
39
# File 'lib/redmine/wiki_formatting/common_mark/markdown_filter.rb', line 34

def call
  doc = CommonMarker.render_doc(@text, parse_options, extensions)
  html = doc.to_html render_options, extensions
  html.rstrip!
  html
end