html-to-react icon indicating copy to clipboard operation
html-to-react copied to clipboard

Strip out white space text nodes

Open RacingTadpole opened this issue 8 years ago • 4 comments

Fixes #30 ("Should not insert spans into tables even if there is white space") by stripping out all white-space text nodes.

This changes non-table nodes too, e.g.: <div> </div> into <div></div> <div> <span>hi</span>bye</div> into <div><span>hi</span>bye</div>.

I'm not sure if that is desirable. If it's not, is there a better solution?

RacingTadpole avatar Apr 04 '16 04:04 RacingTadpole

Coverage Status

Coverage decreased (-1.1%) to 98.876% when pulling a44d4efded8163fabaf9d92600a7395c2b2bd84c on TerriaJS:tablespan into 3bf4bd4b4d45a46e8ce7fcd6af538a3c80eaa7ea on mikenikles:master.

coveralls avatar Apr 04 '16 04:04 coveralls

Might this PR be unnecessary as #30 is already closed?

aknuds1 avatar Jun 27 '16 05:06 aknuds1

Could it be better to leave to some HTML tidying library to handle concerns such as unnecessary whitespace, which this PR addresses?

aknuds1 avatar Sep 18 '16 09:09 aknuds1

Thanks @aknuds1 - I agree, this feels like too heavy a solution to the problem. I like your idea of leaving it to another library to deal with this.

Is it a worry that the test in #30 passes but still produces a warning that a span has been introduced? This may be a spurious comparison, but eg.

<div dangerouslySetInnerHTML={{__html: '<table><tbody> <tr><td>x</td><td>3</td></tr></tbody></table>'}} />

doesn't produce a warning.

RacingTadpole avatar Sep 20 '16 07:09 RacingTadpole