privateOmega / html-to-docx

HTML to DOCX converter
MIT License
373 stars 140 forks source link

bug: when an image is nested under spans, xml-builder doesn't pick up the img tag #233

Open nicolasiscoding opened 8 months ago

nicolasiscoding commented 8 months ago

In the following scenario, the image will not render properly.

<p><span style="font-size: 11pt;"><span style="font-family: Calibri,sans-serif;"><span style="font-size: 12.0pt;"><span style="color: black;"><img src="shortenedbase64string"></span></span></span></span></p>

After triaging, it can be as simple as checking for a vNode here: https://github.com/privateOmega/html-to-docx/blob/2ae805da708e2b3c332cacfe63d0fc55b1c06c89/src/helpers/xml-builder.js#L584

but wanted input on the best way to do this to handle more cases.

Locally, I added another "else if" for this use case and ran the buildImage function. It worked as expected in office for desktop, but did not work for libre. Not an urgent bug as we found a workaround but wanted to add the repro steps here.

nicolasiscoding commented 1 week ago

We have made a hard-fork we maintain here https://www.npmjs.com/package/@turbodocx/html-to-docx