# Watched words 链接损坏 @提及 和 #分类

**URL:** https://meta.discourse.org/t/watched-words-links-corrupt-mentions-and-categories/202161
**Category:** Bug
**Tags:** watched-words
**Created:** [2021年八月30日 19:47 UTC](https://meta.discourse.org/t/watched-words-links-corrupt-mentions-and-categories/202161 "2021-08-30T19:47:04Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)
#### Post date: [2021年八月30日 19:47 UTC](https://meta.discourse.org/t/watched-words-links-corrupt-mentions-and-categories/202161/1 "2021-08-30T19:47:04Z")

</div>

我刚将 @sam 的优秀主题组件 [Auto-Linkify Words](https://meta.discourse.org/t/linkify-words-in-post/82193) 迁移到了较新的核心功能“关注词”。

不幸的是，这导致我们论坛帖子中任何包含“关注词”的 @提及、#分类 和 #标签 都失效了。这类情况相当多。

该主题组件在此方面有相当完善的逻辑——是否可以将这一部分也整合到核心功能中？

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2021年八月31日 02:47 UTC](https://meta.discourse.org/t/watched-words-links-corrupt-mentions-and-categories/202161/2 "2021-08-31T02:47:58Z")

</div>

我明白了，是的，这里确实有些不对劲，@nbianca 大概一周左右可以查看一下。

我们拥有 `DiscourseConnect → https://meta.discourse.org/t/13045`

- [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true)、@DiscourseConnect、#discourseconnect [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true).com.com.fff、[DiscourseConnect](https://meta.discourse.org/t/13045?silent=true)！

我猜问题在于 `@` 和 `#` 应该被视为单词的一部分，而 `#DiscourseConnect` 不应被自动链接？

---

<div class="post-metadata">

### Author: ![Simon\_Manning](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon_manning/32/198596_2.png) [@Simon\_Manning](https://meta.discourse.org/u/Simon_Manning)
#### Post date: [2021年八月31日 12:39 UTC](https://meta.discourse.org/t/watched-words-links-corrupt-mentions-and-categories/202161/3 "2021-08-31T12:39:54Z")

</div>

如果条件允许，最稳妥的做法似乎是：只有在未匹配到 @提及、#分类 或 #标签 时，才应用“关注词”匹配。

这样既可以在关注词与提及/分类/标签发生重叠时保留后者的链接功能，同时也能确保“关注词”仍能捕获如 #非分类非标签 这类内容。

---

<div class="post-metadata">

### Author: ![nbianca](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nbianca/32/157984_2.png) [@nbianca](https://meta.discourse.org/u/nbianca)
#### Post date: [2021年九月9日 15:35 UTC](https://meta.discourse.org/t/watched-words-links-corrupt-mentions-and-categories/202161/5 "2021-09-09T15:35:03Z")

</div>

自该 PR 合并后，以 # 或 @ 开头的词语将不再被替换为其他词语或链接：

> <https://github.com/discourse/discourse/pull/14260>
>
> Watched words of type 'replace' or 'link' replaced the text inside
> mentions or …hashtags too, which broke these. These types of watched
> words must skip any match that has an @ or # before it.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2021年九月10日 06:56 UTC](https://meta.discourse.org/t/watched-words-links-corrupt-mentions-and-categories/202161/6 "2021-09-10T06:56:09Z")

</div>


