smartmarkdown/ts/index.ts
2022-05-20 16:03:35 +02:00

25 lines
743 B
TypeScript

import * as plugins from './smartmarkdown.plugins.js';
import { MdParsedResult } from './smartmarkdown.classes.mdparsedresult.js';
export class SmartMarkdown {
constructor() {}
/**
* create a MdParsedResult from markdown
* @param mdStringArg
*/
public async getMdParsedResultFromMarkdown(mdStringArg: string): Promise<MdParsedResult> {
const result = await MdParsedResult.createFromMarkdownString(mdStringArg);
return result;
};
public htmlToMarkdown(htmlString: string): string {
const turndownInstance = new plugins.turndown({
headingStyle: 'atx',
codeBlockStyle: 'fenced',
});
turndownInstance.use(plugins.turndownPluginGfm.gfm);
return turndownInstance.turndown(htmlString);
}
}