URL 后的一些字符表示主题链接无法工作

我认为这是因为你可以添加诸如 .rss 这样的内容,所以如果你在括号内以链接结尾,并在后面加上句号,Discourse 会认为整个内容都是 URL 的一部分。

[Link: https://meta.discourse.org/t/new-to-discourse-start-here/1.]:

[Link: https://meta.discourse.org/t/new-to-discourse-start-here/1.]

[Link: https://meta.discourse.org/t/new-to-discourse-start-here/1]:

[Link: New to Discourse? Start here!]

[Link: https://meta.discourse.org/t/new-to-discourse-start-here/1?u=jonathan5.]:

[Link: New to Discourse? Start here!]

(Link: https://meta.discourse.org/t/new-to-discourse-start-here/1.):

(Link: https://meta.discourse.org/t/new-to-discourse-start-here/1.)

我不明白你为什么要把句号和感叹号包含在链接中。你为什么那样使用方括号?你这样做的用例是什么?

[链接:https://meta.discourse.org/t/new-to-discourse-start-here/1。]

(有时句子会出现在圆括号或方括号内。)

我可能过度解读了你想做的事情。我猜你只是在谈论方括号的随机使用。是的,在 Markdown 链接中,它们偶尔会破坏链接。

这并不完全是 Markdown 的问题,至少根据 https://markdownviewer.org/ 的表现来看并非如此。在那里,句末的 .) 并不被视为 URL 的一部分,但 .] 却被视为 URL 的一部分。

此外,这并不是“随意使用方括号”,而是指将位于句末且被方括号包裹的 URL 作为整体处理。

是的,欢迎来到 Markdown 中的方括号趣味世界。除非用代码块包裹,否则我从不使用它们。我想 Discourse 应该能对这些进行转义吧?

这是 GitHub - markdown-it/linkify-it: Links recognition library with full unicode support · GitHub 的默认行为。

您可以在 linkify-it demo 上进行测试。

要显式指定链接的起止位置,您可以使用尖括号,如下所示:

[Link: <https://meta.discourse.org/t/new-to-discourse-start-here/1>。]

[Link: https://meta.discourse.org/t/new-to-discourse-start-here/1。]

是的,我正是这样做的(我想我本该把代码贴出来的,哈哈)

知道了,谢谢!编辑:那个链接可以打开,但没有显示主题标题。我还是选择不加句号吧 :slight_smile:

那个链接打不开!

对我来说完全没问题——我觉得引用去掉了尖括号

[链接:https://meta.discourse.org/t/new-to-discourse-start-here/1。]

谢谢大家。看来这是 Markdown 的问题,而不仅仅是 Discourse 的问题。当括号内的句子以 URL 结尾时,有两种可能的解决方案:

  1. 用尖括号将 URL 括起来,但这不会将 URL 显示为主题标题,并且在引用时链接无法正常工作。

  2. 直接省略句号。这就是我在提问之前所做的。