mixmark-io / turndown

🛏 An HTML to Markdown converter written in JavaScript
https://mixmark-io.github.io/turndown
MIT License
8.66k stars 873 forks source link

keep not keeping this HTML use case #344

Open jacargentina opened 4 years ago

jacargentina commented 4 years ago

I need to maintain the YouTube embeds on my HTML when converting to MD.

const TurndownService = require('turndown');
var turndownService = new TurndownService();
turndownService.keep(['iframe']);

const html = `
<p>My video</p>
<div class="video-container">
  <iframe src="https://www.youtube.com/embed/...." width="640" height="360" frameborder="0" allowfullscreen=""></iframe>
</div>`;

console.log(turndownService.turndown(html));

Output

My video

BUT

But if I rework the HTML to a self-closing

nalroff commented 3 years ago

I am also seeing this issue with ins tags created with Google AdSense. Might it be an issue with any empty tag?