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 = @text.delete "\r"
end

Instance Method Details

#callObject



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

def call
  html = Commonmarker.to_html(@text, options: {
                                extension: extensions,
    render: render_options,
    parse: parse_options
                              }, plugins: plugins)

  html.rstrip!
  html
end