Skip to content

Error parsing styles with spaces #73

@vvalchev

Description

@vvalchev

I have the folllowing example:

from html4docx import HtmlToDocx

html = """
<table >
  <tbody>
    <tr >
      <th style="border-top: 1px solid rgb(222, 222, 222)">
        content
      </th>
    </tr>
  </tbody>
</table>
"""

HtmlToDocx().parse_html_string(html)

It fails with

WARNING:root:Could not parse color 'rgb(222,': Invalid color value. Fallback to black.

When I change the border color to use rgb(222, 222, 222) everything works perfectly.

It is importation to mention, that border: 1px solid rgb(222, 222, 222) doesn't fail! But I don't think that it works corectly!

Maybe it's better to use an external library for css parsing. Unfortunately I found only one active CSS library: https://pypi.org/project/tinycss2/

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