From 5c17e462744cb516313729b809e6094e25126e14 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 4 Dec 2018 15:13:34 +1100 Subject: [PATCH] FEATURE: allow advanced specification of excerpts for posts Previously users could control excerpt with `` in Markdown, this is somewhat limited for plugins that need to define this across a section. This adds support for DIV as well --- .../javascripts/pretty-text/white-lister.js.es6 | 1 + spec/components/post_creator_spec.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/assets/javascripts/pretty-text/white-lister.js.es6 b/app/assets/javascripts/pretty-text/white-lister.js.es6 index c303283e360..f8641261da8 100644 --- a/app/assets/javascripts/pretty-text/white-lister.js.es6 +++ b/app/assets/javascripts/pretty-text/white-lister.js.es6 @@ -183,6 +183,7 @@ const DEFAULT_LIST = [ "small", "span[lang]", "span.excerpt", + "div.excerpt", "span.hashtag", "span.mention", "strike", diff --git a/spec/components/post_creator_spec.rb b/spec/components/post_creator_spec.rb index 20f1e82b53f..304491c59cc 100644 --- a/spec/components/post_creator_spec.rb +++ b/spec/components/post_creator_spec.rb @@ -270,6 +270,21 @@ describe PostCreator do }.to_not change { topic.excerpt } end + it 'supports custom excerpts' do + raw = <<~MD +
+ I am + + a custom excerpt +
+ + testing + MD + post = create_post(raw: raw) + + expect(post.excerpt).to eq("I am\na custom excerpt") + end + it 'creates post stats' do Draft.set(user, 'new_topic', 0, "test")