fb55/htmlparser2

Feature request for .innerHtml or something alike

pkese opened this issue · 2 comments

pkese commented

It would be nice to have an option to ask the parser to extract contents of a html tag as clear text without calling event handlers on each inner tag (i.e. just keep collecting text until the end of current open tag).

My use case is to extract contents of <svg>...</svg> tag as text, so that I can pass it to some image drawing library. I'm not interested in parsing what's inside the <svg> tag, I just need contents as text.

Another use case would be to extract contents of <code>...</code> or <pre>...</pre> tags without hitting #1066

The switch to this mode could be defined as setting some sort of a signal (or return code) or calling a function from onopentag code.

pkese commented

Ah, sorry ... I can get that with startIndex and endIndex.

fb55 commented

I can get that with startIndex and endIndex.

That's what I would have recommended as well 🙂