Closed 4www closed 3 years ago
Thanks for the report. Cool to see someone using the customizable options! I'll have a look this weekend. I think the parser is ignoring them by default, but I believe we can get around that.
Thanks again for the thorough report. The issue was that we pre-optimize the tree beforehand to flag as ignored any elements without any children. For speed reasons, this flag happens separately, as it allows us to save a lot of instructions by not having to ask about or instantiate any translator config, etc for these sorts of nodes.
That said, I can certainly see where someone using custom translators would find this to be a hinderance.
In order to maintain performance but allow this functionality, I've added the preserveIfEmpty
option to TranslatorConfig
.
You should be able to accomplish what you need now in v1.1.0, via:
const markdown = NodeHtmlMarkdown.translate(
sHtml,
undefined,
{
iframe: {
preserveIfEmpty: true,
postprocess: () => {
console.log("iframe found");
}
}
}
);
Let me know if that doesn't work for you.
Hej! Thanks a lot for the fix. I will try the new version, really happy to cleanup some of my code :}
Cheers!
hello,
I do not find a way to let the
iframe
element in the final markdown.Would you help me understand what I am missing?
It does not seem that it finds any
iframe
element, with a<iframe/>
or<iframe></iframe>
version.Should'nt the
iframe
keytranslator
be triggered?https://codesandbox.io/s/node-html-markdowniframe-strong-test-n52nb?file=/src/index.js:234-237
Cheers!
Notes
It seems that if the
iframe
is in block version, and as content within its blocks, the iframe is found (with the setup in the link)It there anything missing in the configuration of the
iframe
translator that is missing, or should be setup differently to make it work with single html element version?