-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Table styling #57
base: master
Are you sure you want to change the base?
Table styling #57
Conversation
There was a problem hiding this 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.
if header and row == 0: | ||
for p in cell.paragraphs: | ||
for r in p.runs: | ||
r.font.bold = True |
There was a problem hiding this comment.
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.
styles = [b for a, b in attrs if a == "style" and b] | ||
if styles: | ||
self.style = styles[0] |
There was a problem hiding this comment.
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.
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.