joplin/ReactNativeClient/lib/HtmlToMd.js

20 lines
514 B
JavaScript
Raw Normal View History

const TurndownService = require('joplin-turndown')
const markdownUtils = require('lib/markdownUtils');
2018-05-16 13:16:14 +00:00
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');
let md = turndown.turndown(html)
if (options.baseUrl) md = markdownUtils.prependBaseUrl(md, options.baseUrl);
return md;
2018-05-16 13:16:14 +00:00
}
}
module.exports = HtmlToMd;