BREAKING CHANGE(core): switch to class based design and support html to markdown

This commit is contained in:
2019-06-17 11:56:39 +02:00
parent a66e795432
commit 1361e825fe
7 changed files with 1104 additions and 142 deletions

View File

@ -1,3 +1,21 @@
import * as plugins from './smartmarkdown.plugins';
export const markdownToHtml = (mdString: string): string => plugins.marked(mdString);
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'
});
return turndownInstance.turndown(htmlString);
}
}

View File

@ -1,3 +1,4 @@
import marked = require('marked');
import turndown from 'turndown';
export { marked };
export { marked, turndown };