如何同时使用 div 和具有 data-theme 功能的链接

它在此关于自定义个人样式的帖子中提到,无法直接使用 链接标签,因为它是一个例外,不允许任何 data-attributes。
解决方案是使用 Markdown [链接] 来启用属性的使用,就像这样:

代码:

This <span data-button>[link](https://discourse.org/)</span> use Mardown !

结果:

This link use Mardown !

但是,对于此特定帖子(甚至对于整个 discourse)的结构,我需要使用 HTML 中的

以方便使用,但这似乎会阻止任何 BBCodeMarkdown 被正确解释。因此,在 div 中直接使用 Markdown 链接不起作用

代码:

<div>
This <span data-button>[link](https://discourse.org/)</span> use Mardown in a div !
</div>

结果:

>This [link](https://discourse.org/) use Mardown in a div !

我发现自己无法使用 标签(这会阻止 data-attributes),也无法使用 Markdown 或 BBCode(它们只能在 div 外工作)。

有人能提供解决方案吗?非常感谢。

看看 [wrap],就像 Placeholder Forms 中的那样,也许?

2 个赞

我认为,如果您的开头 div 有任何内容,您应该没问题,例如:

This is some text <div>
This is a very cool [link](https://example.com)!

</div>

变成:

或者甚至一个有空行的 div 也可以:

This is some text

<div>

This is a very cool [link](https://example.com)!

</div>

变成:

5 个赞

太棒了!谢谢您,这两种方法都非常好用!

2 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.