markdown-it / markdown-it-container

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

Need some details about changing default "div" to "aside" #12

Closed john-cj closed 7 years ago

john-cj commented 7 years ago

Hi.

I use browser version. This is what I currently have to init the plugin:

.use(markdownitContainer, 'aside', {
    render: function (tokens, idx) {
        var m = tokens[idx].info.trim().match(/^aside\s+(.*)$/);
        if (tokens[idx].nesting === 1) {
            return '<aside><p class="aside-title">' + md.utils.escapeHtml(m[1]) + '</p>\n';
        } else {
            return '</aside>\n';
        }
    }
});

It successfully works, so

::: aside Note
text
:::

would be converted to

<aside>
    <p class="aside-title">Note</p>
    <p>text</p>
</aside>

But if it possible to get rid of "aside" in Markdown markup?

That's mean,

::: Note
text
:::

should be converted to:

<aside>
    <p class="aside-title">Note</p>
    <p>text</p>
</aside>

As you see, now there is no word "aside" in the Markdown markup, but it was rendered as "aside" in HTML.

Is there way to achieve it? Thanks.