Strip markdown from the heading of a post. Impact notifications, email subjects, SPV <title>, the Atom feed...
This commit is contained in:
parent
ba7f0cf2ed
commit
5dc8642a99
2 changed files with 6 additions and 2 deletions
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue