Skip to content

Conversation

@srepmub
Copy link
Contributor

@srepmub srepmub commented Aug 5, 2020

note that this includes PR 55. I have a patience problem..

so I was wondering if you'd like to include something like the last commit here: we take the "style" attribute from table cells and use it to set fore- and background color for each cell (I didn't bother to write any tests yet).

it would be nicer of course to also get styling from CSS if there, but I couldn't quickly find a nice CSS 'resolver' (?), to get the style for each individual HTML element.

cheers.

Copy link
Member

@francoisfreitag francoisfreitag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Supporting style attributes on cells is a good addition. Perhaps styles could even be defined on thead, tbody, tr, and merged with their descendant to compute the final style. Basically, something like:

<table>
<tr style="color: blue; background: green;">
    <td>Blue text on green background</td>
    <td style="color: black;">Black text on green background</td>
    <td style="color: black; background: white">Black text on white background</td>
</tr>
</table>

Just an idea.

Comment on lines +148 to +151
if header and row == 0:
for p in cell.paragraphs:
for r in p.runs:
r.font.bold = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think everybody wants to have their header row in bold style. However, it would be great to support font-weight as a style attribute or the <b> markup.

Comment on lines +302 to +304
styles = [b for a, b in attrs if a == "style" and b]
if styles:
self.style = styles[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can use the get_attr helper.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants