diff --git a/Changelog.md b/Changelog.md index c73a927f6..7799b26a6 100644 --- a/Changelog.md +++ b/Changelog.md @@ -26,6 +26,7 @@ * Fix login for short passwords [#4123](https://github.com/diaspora/diaspora/issues/4123) * Add loading indicator on tag pages, remove the second one from the profile page [#4041](https://github.com/diaspora/diaspora/issues/4041) * Leaving the `to` field blank when sending a private message causes a server error [#4227](https://github.com/diaspora/diaspora/issues/4227) +* Fix hashtags that start a line when posting to Facebook or Twitter [#3768](https://github.com/diaspora/diaspora/issues/3768) [#4154](https://github.com/diaspora/diaspora/issues/4154) ## Features diff --git a/app/helpers/markdownify_helper.rb b/app/helpers/markdownify_helper.rb index 95f445c41..b59537a1e 100644 --- a/app/helpers/markdownify_helper.rb +++ b/app/helpers/markdownify_helper.rb @@ -3,9 +3,9 @@ # the COPYRIGHT file. module MarkdownifyHelper - def markdownify(target, render_options={}) - markdown_options = { + def markdown_options + { :autolink => true, :fenced_code_blocks => true, :space_after_headers => true, @@ -13,6 +13,9 @@ module MarkdownifyHelper :tables => true, :no_intra_emphasis => true, } + end + + def markdownify(target, render_options={}) render_options[:filter_html] = true render_options[:hard_wrap] ||= true @@ -45,7 +48,7 @@ module MarkdownifyHelper end def strip_markdown(text) - renderer = Redcarpet::Markdown.new(Redcarpet::Render::StripDown, :autolink => true) + renderer = Redcarpet::Markdown.new(Redcarpet::Render::StripDown, markdown_options) renderer.render(text).strip end diff --git a/spec/helpers/markdownify_helper_spec.rb b/spec/helpers/markdownify_helper_spec.rb index 0619944cd..130bc1048 100644 --- a/spec/helpers/markdownify_helper_spec.rb +++ b/spec/helpers/markdownify_helper_spec.rb @@ -83,6 +83,11 @@ describe MarkdownifyHelper do formatted = markdownify(message) formatted.should == %{
Test #tag?
\nhttps://joindiaspora.com