privateOmega/html-to-docx

Support <tr> with no <td> inside

Opened this issue · 1 comments

Per HTML5 spec, a <tr> is allowed to have no children:

4.9.8 The tr element
Content model: Zero or more td, th, and script-supporting elements

But if a <tr></tr> is inserted into the html string, the output file will be corrupted.

I had this issue as well. Microsoft Word couldn't open the files although google docs and Mac textedit were perfectly happy with it.

My solution:
content = content.replace(/(\s+)</tr>/gi, '');