Skip to content

Commit 686789f

Browse files
committed
Support newly added spoiler container syntax
1 parent 398c818 commit 686789f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

src/extension.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,22 @@ export function activate(context: vscode.ExtensionContext) {
198198
md.use(markdownitContainer, 'info', { render });
199199
md.use(markdownitContainer, 'warning', { render });
200200
md.use(markdownitContainer, 'danger', { render });
201+
md.use(markdownitContainer, 'spoiler', {
202+
validate: function (params) {
203+
return params.trim().match(/^spoiler\s+(.*)$/)
204+
},
205+
render: function (tokens, idx) {
206+
var m = tokens[idx].info.trim().match(/^spoiler\s+(.*)$/)
207+
208+
if (tokens[idx].nesting === 1) {
209+
// opening tag
210+
return '<details><summary>' + md.utils.escapeHtml(m[1]) + '</summary>\n'
211+
} else {
212+
// closing tag
213+
return '</details>\n'
214+
}
215+
}
216+
})
201217

202218
md.options.linkify = true;
203219
md.options.typographer = true;

0 commit comments

Comments
 (0)