Merge pull request #5730 from Flaburgan/strip-markdown-from-title
Strip markdown from the heading of a post
This commit is contained in:
commit
f525f9e34d
3 changed files with 7 additions and 2 deletions
|
|
@ -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)
|
* 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)
|
* 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)
|
* 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
|
## Features
|
||||||
* Don't pull jQuery from a CDN by default [#5105](https://github.com/diaspora/diaspora/pull/5105)
|
* Don't pull jQuery from a CDN by default [#5105](https://github.com/diaspora/diaspora/pull/5105)
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@ module Diaspora
|
||||||
atx_content
|
atx_content
|
||||||
end
|
end
|
||||||
|
|
||||||
heading &&= heading.strip
|
heading &&= self.class.new(heading).plain_text_without_markdown
|
||||||
|
|
||||||
if heading && opts[:length]
|
if heading && opts[:length]
|
||||||
heading.truncate opts[:length]
|
heading.truncate opts[:length]
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ describe Diaspora::MessageRenderer do
|
||||||
context 'when :length is passed in parameters' do
|
context 'when :length is passed in parameters' do
|
||||||
it 'returns string of size less or equal to :length' do
|
it 'returns string of size less or equal to :length' do
|
||||||
string_size = 12
|
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
|
expect(title.size).to be <= string_size
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -24,6 +24,10 @@ describe Diaspora::MessageRenderer do
|
||||||
it 'returns setext style header' do
|
it 'returns setext style header' do
|
||||||
expect(message("My title \n======\n Post content...").title).to eq "My title"
|
expect(message("My title \n======\n Post content...").title).to eq "My title"
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
context 'without a Markdown header of less than 200 characters on first line ' do
|
context 'without a Markdown header of less than 200 characters on first line ' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue