A platform for community discussion. Free, open, simple.
FEATURE: adds support for headings in chat (#29552)
Joffrey JAFFEUX279fc846db10
diff --git a/plugins/chat/app/models/chat/message.rb b/plugins/chat/app/models/chat/message.rbindex 7eac16609cf..776f2cfaa52 100644--- a/plugins/chat/app/models/chat/message.rb+++ b/plugins/chat/app/models/chat/message.rb@@ -220,6 +220,7 @@ module Chatblockquoteemphasisreplacements+ heading]def self.cook(message, opts = {})diff --git a/plugins/chat/spec/lib/chat/chat_pretty_text_spec.rb b/plugins/chat/spec/lib/chat/chat_pretty_text_spec.rbdeleted file mode 100644index 680ee0a5a04..00000000000--- a/plugins/chat/spec/lib/chat/chat_pretty_text_spec.rb+++ /dev/null@@ -1,14 +0,0 @@-# frozen_string_literal: true--#-RSpec.describe Chat::Message do- describe ".cook" do- it "renders kbd inline tag" do- cooked = Chat::Message.cook <<~MD- <kbd>Esc</kbd> is pressed- MD-- expect(cooked).to include("<p><kbd>Esc</kbd> is pressed</p>")- end- end-enddiff --git a/plugins/chat/spec/models/chat/message_spec.rb b/plugins/chat/spec/models/chat/message_spec.rbindex 2db7804c48a..06662497758 100644--- a/plugins/chat/spec/models/chat/message_spec.rb+++ b/plugins/chat/spec/models/chat/message_spec.rb@@ -69,10 +69,34 @@ describe Chat::Message do)end- it "does not support headings" do- cooked = described_class.cook("## heading 2")+ it "supports kbd" do+ cooked = described_class.cook <<~MD+ <kbd>Esc</kbd> is pressed+ MD- expect(cooked).to eq("<p>## heading 2</p>")+ expect(cooked).to match_html <<~HTML+ <p><kbd>Esc</kbd> is pressed</p>+ HTML+ end++ it "supports headings" do+ cooked = described_class.cook <<~MD+ # h1+ ## h2+ ### h3+ #### h4+ ##### h5+ ###### h6+ MD++ expect(cooked).to match_html <<~HTML+ <h1><a name="h1-1" class="anchor" href="#h1-1"></a>h1</h1>+ <h2><a name="h2-2" class="anchor" href="#h2-2"></a>h2</h2>+ <h3><a name="h3-3" class="anchor" href="#h3-3"></a>h3</h3>+ <h4><a name="h4-4" class="anchor" href="#h4-4"></a>h4</h4>+ <h5><a name="h5-5" class="anchor" href="#h5-5"></a>h5</h5>+ <h6><a name="h6-6" class="anchor" href="#h6-6"></a>h6</h6>+ HTMLendit "supports horizontal replacement" do