pqzx / html2docx

Convert html to docx
MIT License
69 stars 49 forks source link

Tweak to handle links without href #22

Open djplaner opened 2 years ago

djplaner commented 2 years ago

Thanks for creating and sharing html2docx, much appreciated.

FYI, I had an issue converting some user generated HTML that included a link without a href, throwing an error

File: "...h2d.py", line 514, in handle_data
    self.handle_link(link['href'], data)
KeyError: 'href'

My kludged solution

if link:
    if 'href' in link:
        self.handle_link(link['href'],data)

Not sure if there are broader implications of this, but it serves my immediate purpose.

pqzx commented 2 years ago

Hey @djplaner, thanks for pointing this out. Will look into fixing this for the next release.

lury commented 1 year ago

had this issue today - is there a chance to fix it?