smartmarkdown/ts/index.ts
2021-04-12 09:20:28 +00:00

23 lines
538 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);
}
}