From 58b6f1fd09d1dc35729b49154e68d07153409859 Mon Sep 17 00:00:00 2001 From: Sergey Kishenin Date: Tue, 14 Jul 2015 02:21:44 +0600 Subject: [PATCH] Allow to pass extra options to sir_trevor_markdown helper --- lib/sir_trevor_rails/helpers/view_helper.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/sir_trevor_rails/helpers/view_helper.rb b/lib/sir_trevor_rails/helpers/view_helper.rb index bdef824..db48bc2 100644 --- a/lib/sir_trevor_rails/helpers/view_helper.rb +++ b/lib/sir_trevor_rails/helpers/view_helper.rb @@ -3,10 +3,16 @@ module Helpers module ViewHelper extend ActiveSupport::Concern - def sir_trevor_markdown(text) - rndr = CustomMarkdownFormatter.new(hard_wrap: true, filter_html: true, - autolink: true, no_intraemphasis: true, - fenced_code: true) + DEFAULT_EXTENSIONS = { + hard_wrap: true, + filter_html: true, + autolink: true, + no_intraemphasis: true, + fenced_code: true + } + + def sir_trevor_markdown(text, options = {}) + rndr = CustomMarkdownFormatter.new(DEFAULT_EXTENSIONS.merge(options)) markdown = Redcarpet::Markdown.new(rndr) markdown.render(text).html_safe