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.attrs &&
|
||||
currentToken.attrs.some(
|
||||
(attr) => attr[0] === "class" && attr[1] === "hashtag"
|
||||
(attr) =>
|
||||
attr[0] === "class" &&
|
||||
(attr[1].includes("hashtag") ||
|
||||
attr[1].includes("hashtag-cooked"))
|
||||
)
|
||||
) {
|
||||
lastType =
|
||||
|
|
|
@ -1690,7 +1690,7 @@ HTML
|
|||
SiteSetting.watched_words_regular_expressions = true
|
||||
|
||||
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")
|
||||
|
||||
expect(PrettyText.cook("@test #test test")).to match_html(<<~HTML)
|
||||
|
@ -1700,6 +1700,15 @@ HTML
|
|||
tdiscourset
|
||||
</p>
|
||||
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
|
||||
|
||||
it "supports overlapping words" do
|
||||
|
|
Loading…
Reference in New Issue