Merge pull request #5730 from Flaburgan/strip-markdown-from-title

Strip markdown from the heading of a post
This commit is contained in:
Jonne Haß 2015-03-06 23:41:21 +01:00
commit f525f9e34d
3 changed files with 7 additions and 2 deletions

View file

@ -139,6 +139,7 @@ diaspora.yml file**. The existing settings from 0.4.x and before will not work a
* Total user statistic no longer includes closed accounts [#5041](https://github.com/diaspora/diaspora/pull/5041)
* Don't add a space when rendering a mention [#5711](https://github.com/diaspora/diaspora/pull/5711)
* Fix flickering hovercards [#5714](https://github.com/diaspora/diaspora/pull/5714)
* Improved stripping markdown in post titles [#5730](https://github.com/diaspora/diaspora/pull/5730)
## Features
* Don't pull jQuery from a CDN by default [#5105](https://github.com/diaspora/diaspora/pull/5105)

View file

@ -225,7 +225,7 @@ module Diaspora
atx_content
end
heading &&= heading.strip
heading &&= self.class.new(heading).plain_text_without_markdown
if heading && opts[:length]
heading.truncate opts[:length]

View file

@ -9,7 +9,7 @@ describe Diaspora::MessageRenderer do
context 'when :length is passed in parameters' do
it 'returns string of size less or equal to :length' do
string_size = 12
title = message("## My title\n Post content...").title(length: string_size)
title = message("## This is a really, really, really long title\n Post content").title(length: string_size)
expect(title.size).to be <= string_size
end
end
@ -24,6 +24,10 @@ describe Diaspora::MessageRenderer do
it 'returns setext style header' do
expect(message("My title \n======\n Post content...").title).to eq "My title"
end
it 'returns header without markdown' do
expect(message("## **[My title](http://diasporafoundation.org)**\n Post content...").title).to eq "My title (http://diasporafoundation.org)"
end
end
context 'without a Markdown header of less than 200 characters on first line ' do