smartmarkdown/ts/index.ts
2019-06-17 14:41:57 +02:00

23 lines
537 B
TypeScript

import * as plugins from './smartmarkdown.plugins';
export class SmartMarkdown {
constructor() {}
/**
* converts markdown to html
* @param mdString
*/
public markdownToHtml(mdString: string): string {
return plugins.marked(mdString);
}
public htmlToMarkdown(htmlString): string {
const turndownInstance = new plugins.turndown({
headingStyle: 'atx',
codeBlockStyle: 'fenced'
});
turndownInstance.use(plugins.turndownPluginGfm.gfm);
return turndownInstance.turndown(htmlString);
}
}