diff --git a/src/translator.js b/src/translator.js index 85557d2..3166474 100644 --- a/src/translator.js +++ b/src/translator.js @@ -9,6 +9,7 @@ function initTurndownService() { }); turndownService.use(turndownPluginGfm.tables); + turndownService.keep(['iframe']); // preserve embedded tweets turndownService.addRule('tweet', { @@ -44,11 +45,13 @@ function initTurndownService() { } }); - // preserve iframes (common for embedded audio/video) + // iframe boolean attributes do not need to be set to empty string turndownService.addRule('iframe', { filter: 'iframe', replacement: (content, node) => { - const html = node.outerHTML.replace('allowfullscreen=""', 'allowfullscreen'); + const html = node.outerHTML + .replace('allowfullscreen=""', 'allowfullscreen') + .replace('allowpaymentrequest=""', 'allowpaymentrequest'); return '\n\n' + html + '\n\n'; } }); @@ -70,11 +73,6 @@ function getPostContent(post, turndownService, config) { content = content.replace(/(]*src=").*?([^/"]+\.(?:gif|jpe?g|png))("[^>]*>)/gi, '$1images/$2$3'); } - // this is a hack to make