From 1279dd63bcbbb586a736853ef09951093be441fb Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 17 Oct 2017 22:20:17 +1300 Subject: [PATCH] Reduced complexity of growstuff_markdown --- .rubocop_todo.yml | 5 -- lib/haml/filters/growstuff_markdown.rb | 69 +++++++++++++++----------- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 344c609b0..c162bce19 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -226,11 +226,6 @@ Style/PercentLiteralDelimiters: - 'spec/features/signin_spec.rb' - 'spec/features/signout_spec.rb' -# Cop supports --auto-correct. -Style/PerlBackrefs: - Exclude: - - 'lib/haml/filters/growstuff_markdown.rb' - # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed diff --git a/lib/haml/filters/growstuff_markdown.rb b/lib/haml/filters/growstuff_markdown.rb index e03e8c306..adf4391f6 100644 --- a/lib/haml/filters/growstuff_markdown.rb +++ b/lib/haml/filters/growstuff_markdown.rb @@ -2,55 +2,68 @@ require 'bluecloth' module Haml::Filters module GrowstuffMarkdown + include Haml::Filters::Base + + def render(text) + @expanded = text + expand_crops + expand_members + BlueCloth.new(@expanded).to_html + end + + private + CROP_REGEX = /(?