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

Multiple <span> underlined show errors

Open drawmoon opened this issue 2 years ago • 1 comments

Thanks for this extremely useful library!

I found a problem while using, I have a paragraph of html that does not meet expectations in word, as follows:

html:

<p><span><span>This is an <u>underlined</u> text</span></span></p>

display in word:

This is an underlined text ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯

if I remove the extra <span>, it is normal:

This is an underlined text                 ¯¯¯¯¯¯¯¯¯¯¯

but I can't do that, it was added by other class libraries.

drawmoon avatar Jan 20 '22 03:01 drawmoon

@drawmoon Yes, this seems like a bug from html-to-docx itself, which I was able to reproduce, unfortunately my current bandwidth is very thin and wouldnt permit me to work on this at present and there are other things in list which has more priorirt.

I will keep this open so whenever I can, I will try to fix it whenever I get some time.

I hope as a temporary solution, you could make do with a regex replacement like this,

'<p><span><span>This is an <u>underlined</u> text</span></span></p>'.replace(/<span><span>/i, '<span>').replace(/<\/span><\/span>/i, '<span>')

privateOmega avatar Jan 21 '22 03:01 privateOmega

This might be addressed in https://github.com/privateOmega/html-to-docx/pull/158

nicolasiscoding avatar Nov 08 '22 04:11 nicolasiscoding

<p><span><span>This is an <u>underlined</u> text</span></span></p>

Yes it is, Thank you so much for this PR. Closing this since its addressed in v1.6.0

privateOmega avatar Nov 17 '22 05:11 privateOmega