mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-27 08:21:03 +02:00
21 lines
542 B
JavaScript
21 lines
542 B
JavaScript
const TurndownService = require('joplin-turndown')
|
|
const markdownUtils = require('lib/markdownUtils');
|
|
|
|
class HtmlToMd {
|
|
|
|
parse(html, options = {}) {
|
|
const turndownPluginGfm = require('joplin-turndown-plugin-gfm').gfm
|
|
const turndown = new TurndownService({
|
|
headingStyle: 'atx',
|
|
})
|
|
turndown.use(turndownPluginGfm)
|
|
turndown.remove('script');
|
|
turndown.remove('style');
|
|
let md = turndown.turndown(html)
|
|
if (options.baseUrl) md = markdownUtils.prependBaseUrl(md, options.baseUrl);
|
|
return md;
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = HtmlToMd; |