-
Notifications
You must be signed in to change notification settings - Fork 900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turndown not recognizing <figure> #293
Comments
did you find a solution for it? |
Nope :-( |
The reason is ignored is because it's an empty block element (no text content). You would need to add a blank replacement option when initializing, to preserve figure elements even when empty; something like:
(The blank replacement rule has precedence on everything else, that's why keep and new rules don't seem to work). |
Yes, I think @bambax is correct. I wonder if the blank rule should have a lesser precedence over added rules and keep/remove rules? I think the blank rule had top priority for performance reasons, but perhaps it's not a big issue. What do you think? |
Yes it seems at least 'keep' rules should have priority over blank replacement, because that makes it hard to understand what's happening otherwise. |
I'm trying to convert the following html to markdown:
I want to keep the youtube iframe in my markdown. With default settings turndown returns this:
My friend Alex asked me to teach her how to code and sure thing – we sat down and started hacking! :-)
So, I added the keep option:
turndownService.keep(['figure', 'iframe'])
The result is still the same:
My friend Alex asked me to teach her how to code and sure thing – we sat down and started hacking! :-)
Then I started playing with filters:
The
console.log(node.nodeName)
statement returns me this:As you can see the iframe is found but not the
<figure>
element. Also, the replacement function above doesn't work. I suspect it's because the iframe is wrapped inside the figure element. So I thought I'll just replace the whole figure but that's not possible because turndown doesn't even find it. Why is that?The text was updated successfully, but these errors were encountered: