mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Do not replace hashtag-cooked text with WatchedWords (#19279)
Adds the .hashtag-cooked as an exception for watched words to not auto-link the text of the hashtag.
This commit is contained in:
parent
fb2507c6ce
commit
30e7b716b0
@ -107,7 +107,10 @@ export function setup(helper) {
|
|||||||
currentToken.type === "span_open") &&
|
currentToken.type === "span_open") &&
|
||||||
currentToken.attrs &&
|
currentToken.attrs &&
|
||||||
currentToken.attrs.some(
|
currentToken.attrs.some(
|
||||||
(attr) => attr[0] === "class" && attr[1] === "hashtag"
|
(attr) =>
|
||||||
|
attr[0] === "class" &&
|
||||||
|
(attr[1].includes("hashtag") ||
|
||||||
|
attr[1].includes("hashtag-cooked"))
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
lastType =
|
lastType =
|
||||||
|
@ -1690,7 +1690,7 @@ HTML
|
|||||||
SiteSetting.watched_words_regular_expressions = true
|
SiteSetting.watched_words_regular_expressions = true
|
||||||
|
|
||||||
Fabricate(:user, username: "test")
|
Fabricate(:user, username: "test")
|
||||||
category = Fabricate(:category, slug: "test")
|
category = Fabricate(:category, slug: "test", name: "test")
|
||||||
Fabricate(:watched_word, action: WatchedWord.actions[:replace], word: "es", replacement: "discourse")
|
Fabricate(:watched_word, action: WatchedWord.actions[:replace], word: "es", replacement: "discourse")
|
||||||
|
|
||||||
expect(PrettyText.cook("@test #test test")).to match_html(<<~HTML)
|
expect(PrettyText.cook("@test #test test")).to match_html(<<~HTML)
|
||||||
@ -1700,6 +1700,15 @@ HTML
|
|||||||
tdiscourset
|
tdiscourset
|
||||||
</p>
|
</p>
|
||||||
HTML
|
HTML
|
||||||
|
|
||||||
|
SiteSetting.enable_experimental_hashtag_autocomplete = true
|
||||||
|
expect(PrettyText.cook("@test #test test")).to match_html(<<~HTML)
|
||||||
|
<p>
|
||||||
|
<a class="mention" href="/u/test">@test</a>
|
||||||
|
<a class="hashtag-cooked" href="#{category.url}" data-type="category" data-slug="test"><svg class="fa d-icon d-icon-folder svg-icon svg-node"><use href="#folder"></use></svg><span>test</span></a>
|
||||||
|
tdiscourset
|
||||||
|
</p>
|
||||||
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
it "supports overlapping words" do
|
it "supports overlapping words" do
|
||||||
|
Loading…
Reference in New Issue
Block a user