markdown-it / markdown-it-container

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

Question: is it possible to make the container name optional? #42

Closed mil-ad closed 2 years ago

mil-ad commented 2 years ago

Is it easy to tweak this plugin to make it match any name after :::? I'm looking for something that just adds a <div> with class equals whatever follows :::

puzrin commented 2 years ago

https://github.com/markdown-it/markdown-it-container/blob/master/index.js#L10-L22 see sources. Params are already supported, you only need to modify default renderer.

mil-ad commented 2 years ago

if anybody stumble upon this you can achieve this by:

  1. commenting out the call to validate
  2. commenting out the call to attrJoin in the renderDefault
  3. adding a call to attrJoin in the container function for the opening token: token.attrJoin('class', params.trim().split(' ', 2)[0]);