markdown-it-container icon indicating copy to clipboard operation
markdown-it-container copied to clipboard

Adding multiple classes

Open xplosionmind opened this issue 3 years ago • 4 comments

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>

xplosionmind avatar Mar 24 '22 10:03 xplosionmind

  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.

puzrin avatar Mar 24 '22 10:03 puzrin

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

xplosionmind avatar Mar 24 '22 11:03 xplosionmind

@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>

rrherr avatar Apr 29 '22 07:04 rrherr

@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).

rauschma avatar Sep 15 '22 22:09 rauschma