Merge pull request #2746 from mcwumbly/span-excerpt2
FEATURE: Allow manual excerpt to be defined past the beginning of the po...
This commit is contained in:
commit
9d047c3947
|
@ -63,6 +63,8 @@ class ExcerptParser < Nokogiri::XML::SAX::Document
|
||||||
|
|
||||||
when "div", "span"
|
when "div", "span"
|
||||||
if attributes.include?(["class", "excerpt"])
|
if attributes.include?(["class", "excerpt"])
|
||||||
|
@excerpt = ""
|
||||||
|
@current_length = 0
|
||||||
@start_excerpt = true
|
@start_excerpt = true
|
||||||
end
|
end
|
||||||
# Preserve spoilers
|
# Preserve spoilers
|
||||||
|
|
|
@ -190,12 +190,22 @@ describe PrettyText do
|
||||||
PrettyText.excerpt(nil,100).should == ''
|
PrettyText.excerpt(nil,100).should == ''
|
||||||
end
|
end
|
||||||
|
|
||||||
it "handles span excerpt" do
|
it "handles span excerpt at the beginning of a post" do
|
||||||
PrettyText.excerpt("<span class='excerpt'>hi</span> test",100).should == 'hi'
|
PrettyText.excerpt("<span class='excerpt'>hi</span> test",100).should == 'hi'
|
||||||
post = Fabricate(:post, raw: "<span class='excerpt'>hi</span> test")
|
post = Fabricate(:post, raw: "<span class='excerpt'>hi</span> test")
|
||||||
post.excerpt.should == "hi"
|
post.excerpt.should == "hi"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "handles span excerpt that starts before the max length" do
|
||||||
|
text = "123456789 123456789 12345679 123456789 123456789 " +
|
||||||
|
"as long as span starts before max length of the " +
|
||||||
|
"<span class='excerpt'>the specified excerpt</span>" +
|
||||||
|
"of the post will be used"
|
||||||
|
PrettyText.excerpt(text, 100).should == 'the specified excerpt'
|
||||||
|
post = Fabricate(:post, raw: text)
|
||||||
|
post.excerpt.should == 'the specified excerpt'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "strip links" do
|
describe "strip links" do
|
||||||
|
|
Loading…
Reference in New Issue