I am trying to add Markdown support in Rails 7.1.1 app.
Redcarpet gem version is 3.6.0.
I follow advice from this question:
Using ERB in Markdown with Redcarpet
My current code (in /config/initializers/markdown_handler.rb
) is:
module MarkdownHandler
def self.erb
@erb ||= ActionView::Template.registered_template_handler(:erb)
end
def self.call(template, source)
compiled_source = erb.call(template, source)
"Redcarpet::Markdown.new(Redcarpet::Render::HTML.new).render(begin;#{compiled_source};end).html_safe"
end
end
ActionView::Template.register_template_handler :md, MarkdownHandler
And I get an error:
ActionView::Template::Error: wrong argument type ActionView::OutputBuffer (expected String)
Could someone kindly explain why is it happening and how to fix it, please?