smartmarkdown/ts/index.ts

25 lines
743 B
TypeScript
Raw Permalink Normal View History

2022-05-19 07:36:59 +00:00
import * as plugins from './smartmarkdown.plugins.js';
2022-05-20 14:03:35 +00:00
import { MdParsedResult } from './smartmarkdown.classes.mdparsedresult.js';
2018-09-22 19:58:33 +00:00
export class SmartMarkdown {
constructor() {}
/**
2022-05-20 14:03:35 +00:00
* create a MdParsedResult from markdown
* @param mdStringArg
*/
2022-05-20 14:03:35 +00:00
public async getMdParsedResultFromMarkdown(mdStringArg: string): Promise<MdParsedResult> {
const result = await MdParsedResult.createFromMarkdownString(mdStringArg);
return result;
};
2021-10-04 11:35:20 +00:00
public htmlToMarkdown(htmlString: string): string {
const turndownInstance = new plugins.turndown({
headingStyle: 'atx',
2021-04-12 09:20:28 +00:00
codeBlockStyle: 'fenced',
});
2019-06-17 12:41:57 +00:00
turndownInstance.use(plugins.turndownPluginGfm.gfm);
return turndownInstance.turndown(htmlString);
}
}