FIX: properly create a mention when followed by dots (#23829)
At the moment writing a mention similar to `@bob...hi` would have resulted in chat trying to find a user named `bob...hi` which would fail.
This was due to the `replacements` rule not being present in the rules used to cook chat messages.
We are still missing few default rules like: normalize, smartquotes, text_join, ... which don't seem to be necessary but could be added if we found a reason for. More info at: e476f78bc3/lib/parser_core.js
This commit is contained in:
parent
79ececd976
commit
dfe840f71d
|
@ -211,6 +211,7 @@ module Chat
|
|||
strikethrough
|
||||
blockquote
|
||||
emphasis
|
||||
replacements
|
||||
]
|
||||
|
||||
def self.cook(message, opts = {})
|
||||
|
|
|
@ -20,16 +20,25 @@ describe Chat::Message do
|
|||
expect(cooked).to eq("<p><h1>test</h1></p>")
|
||||
end
|
||||
|
||||
it "correctly extracts mentions with dots" do
|
||||
user = Fabricate(:user)
|
||||
cooked = described_class.cook("@#{user.username}...test")
|
||||
|
||||
expect(cooked).to eq(
|
||||
"<p><a class=\"mention\" href=\"/u/#{user.username}\">@#{user.username}</a>…test</p>",
|
||||
)
|
||||
end
|
||||
|
||||
it "does not support headings" do
|
||||
cooked = described_class.cook("## heading 2")
|
||||
|
||||
expect(cooked).to eq("<p>## heading 2</p>")
|
||||
end
|
||||
|
||||
it "does not support horizontal rules" do
|
||||
it "supports horizontal replacement" do
|
||||
cooked = described_class.cook("---")
|
||||
|
||||
expect(cooked).to eq("<p>---</p>")
|
||||
expect(cooked).to eq("<p>—</p>")
|
||||
end
|
||||
|
||||
it "supports backticks rule" do
|
||||
|
@ -95,7 +104,7 @@ describe Chat::Message do
|
|||
<div class="quote-controls"></div>
|
||||
<img loading="lazy" alt="" width="24" height="24" src="#{avatar_src}" class="avatar"><a href="http://test.localhost/t/some-quotable-topic/#{topic.id}/#{post.post_number}">#{topic.title}</a></div>
|
||||
<blockquote>
|
||||
<p>Mark me...this will go down in history.</p>
|
||||
<p>Mark me…this will go down in history.</p>
|
||||
</blockquote>
|
||||
</aside>
|
||||
COOKED
|
||||
|
|
Loading…
Reference in New Issue