Skip to content

height and width attributes of <img> tag not properly handled #76

@NagNagash

Description

@NagNagash

Hello,

According to this, the height and width attributes of the <img> tag are in pixels and must not have a unit. However, the unit_converter() function in utils.py returns None when no unit is specified.

Maybe the unit variable should default to "px" in this case ?

Sample :

from html4docx import HtmlToDocx
parser = HtmlToDocx()
docx = parser.parse_html_string('<img src="test.jpg" width="256" height="256">')

Output :

Warning: unsupported unit , return None instead.
Warning: unsupported unit , return None instead.`

And the image is not correctly sized in the document.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions