You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm testing turndown on a page that includes sample python code with comments, example:
<span class="comment"># here's a comment</span>.
There are no pre or code tags used in the HTML. Each time I run turndown, it results in this line being output as is and displaying like an H1:
here's a comment
Here is the rule I'm using to attempt to excude these:
// handle potential code comments or lines starting with "#" in <span> tagsturndownService.addRule('spanWithHash',{filter: (node)=>{consthasHash=node.nodeName==='SPAN'&&node.textContent.trim().startsWith('#');if(hasHash){console.log("Found span filter #: ",node.textContent.trim());// log for debugging}returnhasHash;},replacement: (content,node)=>{returncontent.trim().substring(1);}});
I also tried escaping etc before deciding to try remove the # all together. Despite this, the text within these tags is still being treated as headers in the resulting markdown.
Could you help identify why this rule isn't working as intended?
The text was updated successfully, but these errors were encountered:
Hi,
I'm testing turndown on a page that includes sample python code with comments, example:
<span class="comment"># here's a comment</span>.
There are no pre or code tags used in the HTML. Each time I run turndown, it results in this line being output as is and displaying like an H1:
here's a comment
Here is the rule I'm using to attempt to excude these:
I also tried escaping etc before deciding to try remove the # all together. Despite this, the text within these tags is still being treated as headers in the resulting markdown.
Could you help identify why this rule isn't working as intended?
The text was updated successfully, but these errors were encountered: