I saw you wanted it to fix this bug -- Whitespace text nodes cannot appear as a child of <table>
-- in the html-to-react
package.
I encountered the same bug -- I'm using the following to fix it (where sliced
in this example in the name of the string which contains the HTML):
// React expect no whitespace between table elements
sliced = sliced.replace(/<table>\s*<thead>/g, "<table><thead>");
sliced = sliced.replace(/<table>\s*<tbody>/g, "<table><tbody>");
sliced = sliced.replace(/<thead>\s*<tr>/g, "<thead><tr>");
sliced = sliced.replace(/<tbody>\s*<tr>/g, "<tbody><tr>");
sliced = sliced.replace(/<tr>\s*<th>/g, "<tr><th>");
sliced = sliced.replace(/<tr>\s*<td>/g, "<tr><td>");
sliced = sliced.replace(/<\/thead>\s*<tbody>/g, "</thead><tbody>");
sliced = sliced.replace(/<\/thead>\s*<\/table>/g, "</thead></table>");
sliced = sliced.replace(/<\/tbody>\s*<\/table>/g, "</tbody></table>");
sliced = sliced.replace(/<\/tr>\s*<\/thead>/g, "</tr></thead>");
sliced = sliced.replace(/<\/tr>\s*<\/tbody>/g, "</tr></tbody>");
sliced = sliced.replace(/<\/th>\s*<\/tr>/g, "</th></tr>");
sliced = sliced.replace(/<\/td>\s*<\/tr>/g, "</td></tr>");
sliced = sliced.replace(/<\/tr>\s*<tr>/g, "</tr><tr>");
sliced = sliced.replace(/<\/th>\s*<th>/g, "</th><th>");
sliced = sliced.replace(/<\/td>\s*<td>/g, "</td><td>");
That (using regular expressions) is assuming it's regular HTML and not "arbitrary" HTML.