markdown-it / markdown-it-container

Fenced container plugin for markdown-it markdown parser
MIT License
496 stars 74 forks source link

Adding multiple classes #44

Closed xplosionmind closed 9 months ago

xplosionmind commented 2 years ago

I am referring to #23 in requesting if it is possible to add a toggle that enables/disables multiple classes as the generated div name. I already checked the source code, but I think it would be better not to make each user customize the code, but rather providing standard options and toggles. In my case, I lack the knowledge to directly manipulate the JavaScript of this extension.

E.g.

::: yellow box
### Hello
:::
<div class='yellow box'>
<h4>Hello</h4>
</div>
puzrin commented 2 years ago
  1. Policy to leave all for customization is intended, to not poison api with zillion of rare options.
  2. Refer to added value for "many users" should have concrete proofs. At current moment only you requested such feature. As alternative, you could publish package with your vision of api.
xplosionmind commented 2 years ago

I believe that the issue I referenced was another user with the same need…

rrherr commented 2 years ago

@xplosionmind you could do it using markdown-it-attrs & markdown-it-container together:

::: custom {.yellow .box}
### Hello
:::
<div class='custom yellow box'>
<h3>Hello</h3>
</div>
rauschma commented 1 year ago

@rrherr That looks nice!

It’s interesting to compare markdown-it-container + markdown-it-attrs with Pandoc’s syntax for “fenced divs”:

::: single-class
:::

::: {.class1of2 .class2of2}
:::

::: {.single-class id=my-id}
:::

That is: It interprets a single name as a class name. As soon as you adds another attribute, you have to switch to attributes in braces (with markdown-it-attrs syntax).