Closed scil closed 7 years ago
I want to control the tag name of rendered html, e.g. z-deep/section instead of div.
.use(require('markdown-it-container'), 'decorate' , { validate: function(params) { return params.trim().match(/^(z-deep|section)$/); }, render: function (tokens, idx) { var m = tokens[idx].info.trim().match(/^(z-deep|section)$/); var tag=m[1]||'div'; if (tokens[idx].nesting === 1) { // opening tag return '<' + tag + ' >\n'; } else { // closing tag console.log('tag ',tag) return '</'+tag+'>\n'; } }
but the closing tag always is 'div', for example
::: z-deep ok :::
output:
<z-deep> <p>ok</p> </div>
Your regexp doesn't match closing tag and you use div then. You can add console.log to renderer and see what happens.
console.log
I want to control the tag name of rendered html, e.g. z-deep/section instead of div.
but the closing tag always is 'div', for example
output: