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 experimenting with parse5-html-rewriting-stream and not seeing an easy way to remove/delete an element along with all children. Not emitting a tag removes that particular tag from output, but the children are still included. This seems counter-intuitive to me, but maybe I'm missing something simple.
The text was updated successfully, but these errors were encountered:
This is not something that's particularly easy to do with the rewriting stream. One approach would be:
// Remove all `article` tags and their contentsletarticleCount=0;functionemitIfOutsideArticle(_token,raw){if(articleCount===0){rewriter.emitRaw(raw);}}rewriter.on('startTag',(tag,raw)=>{if(tag.tagName==='article'){articleCount+=1;}else{rewriter.emitRaw(raw);}});rewriter.on('endTag',(tag,raw)=>{if(articleCount>0&&tag.tagName==='article'){articleCount-=1;}emitIfOutsideArticle(tag,raw)});for(leteventNameof['text','doctype','comment']){rewriter.on(eventName,emitIfOutsideArticle);}
I'm experimenting with parse5-html-rewriting-stream and not seeing an easy way to remove/delete an element along with all children. Not emitting a tag removes that particular tag from output, but the children are still included. This seems counter-intuitive to me, but maybe I'm missing something simple.
The text was updated successfully, but these errors were encountered: