Fix hashtags that start a line when posting to Facebook or Twitter, by applying all the same options to strip_markdown as applying to markdownify, fixes #3768 and #4154
This commit is contained in:
parent
221c1bf959
commit
f30cee3b6e
3 changed files with 17 additions and 3 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
* Fix login for short passwords [#4123](https://github.com/diaspora/diaspora/issues/4123)
|
* 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)
|
* 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)
|
* 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
|
## Features
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
# the COPYRIGHT file.
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
module MarkdownifyHelper
|
module MarkdownifyHelper
|
||||||
def markdownify(target, render_options={})
|
|
||||||
|
|
||||||
markdown_options = {
|
def markdown_options
|
||||||
|
{
|
||||||
:autolink => true,
|
:autolink => true,
|
||||||
:fenced_code_blocks => true,
|
:fenced_code_blocks => true,
|
||||||
:space_after_headers => true,
|
:space_after_headers => true,
|
||||||
|
|
@ -13,6 +13,9 @@ module MarkdownifyHelper
|
||||||
:tables => true,
|
:tables => true,
|
||||||
:no_intra_emphasis => true,
|
:no_intra_emphasis => true,
|
||||||
}
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def markdownify(target, render_options={})
|
||||||
|
|
||||||
render_options[:filter_html] = true
|
render_options[:filter_html] = true
|
||||||
render_options[:hard_wrap] ||= true
|
render_options[:hard_wrap] ||= true
|
||||||
|
|
@ -45,7 +48,7 @@ module MarkdownifyHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def strip_markdown(text)
|
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
|
renderer.render(text).strip
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,11 @@ describe MarkdownifyHelper do
|
||||||
formatted = markdownify(message)
|
formatted = markdownify(message)
|
||||||
formatted.should == %{<p>Test <a href="/tags/tag" class="tag">#tag</a>?<br>\n<a href="https://joindiaspora.com" target="_blank">https://joindiaspora.com</a></p>\n}
|
formatted.should == %{<p>Test <a href="/tags/tag" class="tag">#tag</a>?<br>\n<a href="https://joindiaspora.com" target="_blank">https://joindiaspora.com</a></p>\n}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should process text with a header' do
|
||||||
|
message = "# I love markdown"
|
||||||
|
markdownify(message).should match "I love markdown"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -91,5 +96,10 @@ describe MarkdownifyHelper do
|
||||||
message = "some text and here comes http://exampe.org/foo_bar_baz a link"
|
message = "some text and here comes http://exampe.org/foo_bar_baz a link"
|
||||||
strip_markdown(message).should match message
|
strip_markdown(message).should match message
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'does not destroy hashtag that starts a line' do
|
||||||
|
message = "#hashtag message"
|
||||||
|
strip_markdown(message).should match message
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue