Skip to content
Extraits de code Groupes Projets
Valider 8236e65f rédigé par Jonne Haß's avatar Jonne Haß
Parcourir les fichiers

Merge pull request #4240 from jaywink/3768-hashmark-first-character

Fix hashtags that start a line when posting to Facebook or Twitter
parents 221c1bf9 f30cee3b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -26,6 +26,7 @@ ...@@ -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 @@ ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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 ...@@ -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
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter