FEATURE: adds support for headings in chat (#29552)
``` ``` Will now be converted into their html versions: <h1>, <h2>, <h3>, ...
This commit is contained in:
parent
b81055a6d4
commit
279fc846db
|
@ -220,6 +220,7 @@ module Chat
|
|||
blockquote
|
||||
emphasis
|
||||
replacements
|
||||
heading
|
||||
]
|
||||
|
||||
def self.cook(message, opts = {})
|
||||
|
|
|
@ -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
|
||||
end
|
|
@ -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>
|
||||
HTML
|
||||
end
|
||||
|
||||
it "supports horizontal replacement" do
|
||||
|
|
Loading…
Reference in New Issue