BREAKING CHANGE(core): switch to class based design and support html to markdown
This commit is contained in:
20
ts/index.ts
20
ts/index.ts
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import marked = require('marked');
|
||||
import turndown from 'turndown';
|
||||
|
||||
export { marked };
|
||||
export { marked, turndown };
|
||||
|
Reference in New Issue
Block a user