mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-25 16:28:24 -04:00
updated regex for crop in markdown
This commit is contained in:
1 parent
374c17c928
commit
dd75f2aef9
2 files changed
+11
-1
No files matched your search
@@ -7,7 +7,7 @@ module Haml::Filters
|
||||
def render(text)
|
||||
|
||||
# turn [tomato](crop) into [tomato](http://growstuff.org/crops/tomato)
|
||||
expanded = text.gsub(/\[(.*?)\]\(crop\)/) do |m|
|
||||
expanded = text.gsub(/\[([^\[\]]+?)\]\(crop\)/) do |m|
|
||||
crop_str = $1
|
||||
# find crop case-insensitively
|
||||
crop = Crop.where('lower(name) = ?', crop_str.downcase).first
|
||||
|
||||
@@ -52,4 +52,14 @@ describe 'Haml::Filters::Growstuff_Markdown' do
|
||||
rendered.should match /#{output_link(@crop, 'ToMaTo')}/
|
||||
end
|
||||
|
||||
|
||||
it "doesn't convert when it's not followed by '(crop)'" do
|
||||
tomato = FactoryGirl.create(:tomato)
|
||||
maize = FactoryGirl.create(:maize)
|
||||
string = "[maize](http://example.com) #{input_link(tomato)}"
|
||||
rendered = Haml::Filters::GrowstuffMarkdown.render(string)
|
||||
rendered.should match /#{output_link(tomato)}/
|
||||
rendered.should_not match /#{output_link(maize)}/
|
||||
rendered.should match "<a href=\"http://example.com\">maize</a>"
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user