How to use both <div> and link with data-theme features

It’s said in this post on customizing personal styles that it’s not possible to use an <a> link tag directly because it’s an exception and doesn’t allow any data-attributes.
The solution is to use a Markdown [link] to enable the use of attributes, just like this :

Code :

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

Result :

This link use Mardown !

However, for the structure of this specific post (and even for the all discourse), I need to use <div> in html for ease of use, but this seems to prevent any BBCode or markdown from being corectively interpreted. So using markdown links doesn’t work directly in a div.

Code :

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

Result :

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

I find myself unable to use <a> tags, which prevent data-atributes, and unable to use markdown or BBCode, which only work outside divs.

Can anyone suggest a solution ? Thank you so much.

Have a look at [wrap] like in Placeholder Forms, maybe?

2 Likes

I think if you have anything on the line with the opening div you should be fine, e.g.:

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

Becomes:

Or even a gapped div should work:

This is some text
<div>

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

Becomes:

5 Likes

YES ! Thank you , the 2 methods work very well !

2 Likes

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