// compile: tsc showdown/showdown-tests.ts --noImplicitAny --module commonjs // run: node showdown/showdown-tests.js import showdown = require('showdown'); var exampleMarkdown = '#hello, markdown', exampleHTML = '
*hello, markdown
' console.log(multipleExtensionsConverter.makeHtml(exampleMarkdown)); // should log '*Hello showdown
' console.log(configuredConverter.makeHtml(exampleMarkdown)); // should log '*hello,_markdown' console.log(converter.makeMarkdown(exampleHTML)); // should log '#hello, markdown' configuredConverter.useExtension('listen-ext'); configuredConverter.addExtension(commaExt); configuredConverter.addExtension([combinedExt]); configuredConverter.addExtension(() => markdownToShowdownExt); configuredConverter.removeExtension(combinedExt); configuredConverter.addExtension(() => [listenToCodeBlocksExt, combinedExt]); configuredConverter.listen('unescapeSpecialChars.after', (evtName, text) => `"${ text }"`); showdown.extension('myExt', function () { var matches: string[] = []; return [ { type: 'lang', regex: /%start%([^]+?)%end%/gi, replace: function (s: string, match: string) { matches.push(match); var n = matches.length - 1; return '%PLACEHOLDER' + n + '%'; } }, { type: 'output', filter: function (text) { for (var i = 0; i < matches.length; ++i) { var pat = '%PLACEHOLDER' + i + '% *<\/p>'; text = text.replace(new RegExp(pat, 'gi'), matches[i]); } // reset array matches = []; return text; } } ] }); showdown.extension('myExt'); showdown.removeExtension('myExt'); showdown.extension('myExt', someExtArray); showdown.resetExtensions() showdown.extension('commaExt', () => commaExt) showdown.validateExtension(markdownToShowdownExt); showdown.validateExtension([markdownToShowdownExt, markdownToShowdownExt]) showdown.setOption('noHeaderId', true); showdown.setOption('foo', 'bar'); // custom option converter.setOption('tables', true); converter.setOption('color', 'red'); // custom option showdown.setFlavor('github'); console.log(showdown.getFlavor()); // should log 'github' converter.setFlavor('ghost'); console.log(converter.getFlavor()); // should log 'ghost'