File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( / ^ s p o i l e r \s + ( .* ) $ / )
204+ } ,
205+ render : function ( tokens , idx ) {
206+ var m = tokens [ idx ] . info . trim ( ) . match ( / ^ s p o i l e r \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 ;
You can’t perform that action at this time.
0 commit comments