From e912bf3edad31764a96ba22f19b93de7d1c8a9b0 Mon Sep 17 00:00:00 2001 From: Pistos Date: Tue, 1 Nov 2011 23:35:21 -0400 Subject: [PATCH 1/2] Whitespace cleanup. --- app/helpers/markdownify_helper.rb | 4 ++-- spec/helpers/markdownify_helper_spec.rb | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/helpers/markdownify_helper.rb b/app/helpers/markdownify_helper.rb index 9ba17f019..8c679201a 100644 --- a/app/helpers/markdownify_helper.rb +++ b/app/helpers/markdownify_helper.rb @@ -19,7 +19,7 @@ module MarkdownifyHelper render_options[:filter_html] = true render_options[:hard_wrap] ||= true - # This ugly little hack basically means + # This ugly little hack basically means # "Give me the rawest contents of target available" if target.respond_to?(:raw_message) message = target.raw_message @@ -39,7 +39,7 @@ module MarkdownifyHelper if target.respond_to?(:format_mentions) message = target.format_mentions(message) end - + message = Diaspora::Taggable.format_tags(message, :no_escape => true) return message.html_safe diff --git a/spec/helpers/markdownify_helper_spec.rb b/spec/helpers/markdownify_helper_spec.rb index ed73c7d1b..51c7704c7 100644 --- a/spec/helpers/markdownify_helper_spec.rb +++ b/spec/helpers/markdownify_helper_spec.rb @@ -9,7 +9,7 @@ describe MarkdownifyHelper do describe "#markdownify" do describe "not doing something dumb" do it "strips out script tags" do - markdownify("").should == + markdownify("").should == "

alert('XSS is evil')

\n" end @@ -35,7 +35,7 @@ describe MarkdownifyHelper do context 'when formatting status messages' do it "should leave tags intact" do - message = Factory.create(:status_message, + message = Factory.create(:status_message, :author => alice.person, :text => "I love #markdown") formatted = markdownify(message) @@ -43,7 +43,7 @@ describe MarkdownifyHelper do end it "should leave mentions intact" do - message = Factory.create(:status_message, + message = Factory.create(:status_message, :author => alice.person, :text => "Hey @{Bob; #{bob.diaspora_handle}}!") formatted = markdownify(message) @@ -52,7 +52,7 @@ describe MarkdownifyHelper do it "should leave mentions intact for real diaspora handles" do new_person = Factory(:person, :diaspora_handle => 'maxwell@joindiaspora.com') - message = Factory.create(:status_message, + message = Factory.create(:status_message, :author => alice.person, :text => "Hey @{maxwell@joindiaspora.com; #{new_person.diaspora_handle}}!") formatted = markdownify(message) From db4bfb73a9c03a6c1541c08be2c0ac8e2f50ebb9 Mon Sep 17 00:00:00 2001 From: Pistos Date: Tue, 1 Nov 2011 23:35:34 -0400 Subject: [PATCH 2/2] Fix issue #2213: multi-underscore hashtags no longer get Markdown phasis applied. --- app/helpers/markdownify_helper.rb | 3 ++- spec/helpers/markdownify_helper_spec.rb | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/helpers/markdownify_helper.rb b/app/helpers/markdownify_helper.rb index 8c679201a..bcac67dab 100644 --- a/app/helpers/markdownify_helper.rb +++ b/app/helpers/markdownify_helper.rb @@ -13,7 +13,8 @@ module MarkdownifyHelper :space_after_headers => true, :strikethrough => true, :superscript => true, - :tables => true + :tables => true, + :no_intra_emphasis => true, } render_options[:filter_html] = true diff --git a/spec/helpers/markdownify_helper_spec.rb b/spec/helpers/markdownify_helper_spec.rb index 51c7704c7..b5d22bb8d 100644 --- a/spec/helpers/markdownify_helper_spec.rb +++ b/spec/helpers/markdownify_helper_spec.rb @@ -42,6 +42,24 @@ describe MarkdownifyHelper do formatted.should =~ %r{#markdown} end + it 'should leave multi-underscore tags intact' do + message = Factory.create( + :status_message, + :author => alice.person, + :text => "Here is a #multi_word tag" + ) + formatted = markdownify(message) + formatted.should =~ %r{Here is a #multi_word tag} + + message = Factory.create( + :status_message, + :author => alice.person, + :text => "Here is a #multi_word_tag yo" + ) + formatted = markdownify(message) + formatted.should =~ %r{Here is a #multi_word_tag yo} + end + it "should leave mentions intact" do message = Factory.create(:status_message, :author => alice.person,