markdown-it / markdown-it-container

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

Container inside code blocks #41

Closed AllanJard closed 2 years ago

AllanJard commented 2 years ago

Hi,

Is there a way to use a container inside a code block? I'm hoping to use it for some example code combined with a markdown condition - e.g.:

```js
::: handlebars {{#if selfHostedDocs}}
// Do 1
::: handlebars {{else}}
// Do 2
::: handlebars {{/if}}


I know I could put the container outside the code block, but it then goes on to to other code stuff that isn't conditional, so this would simplify things.

Many thanks!
AllanJard commented 2 years ago

Been reading a bit more about this and it seems the Markdown parser won't parse stuff inside the fenced code block. So this can't work. But with that information I can do simply:

```js
{{#if selfHostedDocs}}
// Do 1
{{else}}
// Do 2
{{/if}}


Then Handlebars can run on that. That will do nicely for my use case :-)