Unable to set table column width on tables td's if a th exists #172

Closed
stevenlaidlaw opened this Issue Mar 6, 2014 · 11 comments

Comments

Projects
None yet
4 participants
@stevenlaidlaw

If a 'table > thead > tr > th' is set, weasy is not able to set the column widths on td's below it. This is a problem when trying to set widths on table columns where the table header has a colspan greater than 1.

Example:

<table>
    <thead> 
        <tr>
            <th colspan="2">The column width will not work in weasy</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Hello</td>
            <td>Clarice</td>
        </tr>
    </tbody>
</table>
table > tbody > tr > td:first-child {
    width: 20%;
    text-align: left;
}
@SimonSapin

This comment has been minimized.

Show comment
Hide comment
@SimonSapin

SimonSapin Mar 7, 2014

Member

I wouldn’t be surprised if we do colspan wrong in the automatic column width algorithm. @liZe does that ring a bell?

Member

SimonSapin commented Mar 7, 2014

I wouldn’t be surprised if we do colspan wrong in the automatic column width algorithm. @liZe does that ring a bell?

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe Mar 7, 2014

Member

I think that percentages are not handled at all when no width is set to the table, even without colspans. I'll check that.

Member

liZe commented Mar 7, 2014

I think that percentages are not handled at all when no width is set to the table, even without colspans. I'll check that.

@SimonSapin

This comment has been minimized.

Show comment
Hide comment
@SimonSapin

SimonSapin Mar 7, 2014

Member

http://dbaron.org/css/intrinsic/ describes algorithms we could implement to handle this kind of thing. At the moment, it’s the closest thing in existence to a spec of what browsers do.

Member

SimonSapin commented Mar 7, 2014

http://dbaron.org/css/intrinsic/ describes algorithms we could implement to handle this kind of thing. At the moment, it’s the closest thing in existence to a spec of what browsers do.

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe Mar 7, 2014

Member

Soooooo easyyyyyyyy!

Member

liZe commented Mar 7, 2014

Soooooo easyyyyyyyy!

@SimonSapin

This comment has been minimized.

Show comment
Hide comment
@SimonSapin

SimonSapin Mar 7, 2014

Member

Of course. It’s just a small matter of programming :)

Member

SimonSapin commented Mar 7, 2014

Of course. It’s just a small matter of programming :)

@stevenlaidlaw

This comment has been minimized.

Show comment
Hide comment
@stevenlaidlaw

stevenlaidlaw Mar 11, 2014

Apologies, I should have clarified that even with a table width of 100% and table-layout of fixed this still happens, but from what you've written in response it seems like you're onto it anyway. :)

Apologies, I should have clarified that even with a table width of 100% and table-layout of fixed this still happens, but from what you've written in response it seems like you're onto it anyway. :)

@eldamir

This comment has been minimized.

Show comment
Hide comment
@eldamir

eldamir Jan 4, 2016

This is still a real pain. Any fix available?

I have a table with 6 columns, and each column has a width set, which looks great in Chrome, but with weasyprint, these widths are ignored, and all columns seem to be equally distributed 😦

eldamir commented Jan 4, 2016

This is still a real pain. Any fix available?

I have a table with 6 columns, and each column has a width set, which looks great in Chrome, but with weasyprint, these widths are ignored, and all columns seem to be equally distributed 😦

@stevenlaidlaw

This comment has been minimized.

Show comment
Hide comment
@stevenlaidlaw

stevenlaidlaw Jan 7, 2016

I don't think anyone is working on Weasy anymore. The hacky workaround I use is just to have an invisible th row above the normal one, and hide all the margins, padding, borders, etc, then just set the widths on that. It's bad code, but it's what you have to do to get it working in Weasy :(

I don't think anyone is working on Weasy anymore. The hacky workaround I use is just to have an invisible th row above the normal one, and hide all the margins, padding, borders, etc, then just set the widths on that. It's bad code, but it's what you have to do to get it working in Weasy :(

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe Jan 12, 2016

Member

You can look at #291.

Your specific case is maybe the worst case for this algorithm (the width of the table is a too high, it's the same rendering as Chrome for example), but at least it takes care of the percentages. It's much better for other cases.

Feel free to tests and reports bugs!

Member

liZe commented Jan 12, 2016

You can look at #291.

Your specific case is maybe the worst case for this algorithm (the width of the table is a too high, it's the same rendering as Chrome for example), but at least it takes care of the percentages. It's much better for other cases.

Feel free to tests and reports bugs!

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe Jan 15, 2016

Member

@eldamir @stevenlaidlaw last call for tests! You can try #291 if you want.

Member

liZe commented Jan 15, 2016

@eldamir @stevenlaidlaw last call for tests! You can try #291 if you want.

@liZe

This comment has been minimized.

Show comment
Hide comment
@liZe

liZe Jan 25, 2016

Member

@eldamir @stevenlaidlaw it's merged in master.

Member

liZe commented Jan 25, 2016

@eldamir @stevenlaidlaw it's merged in master.

@liZe liZe closed this Jan 25, 2016

jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Feb 19, 2016

kleink
Update py-weasyprint to 0.26.
Version 0.26
------------

Released on 2016-01-29.

New features:

* Support the `empty-cells` attribute.
* Respect table, column and cell widths.

Bug fixes:

* `#172: <Kozea/WeasyPrint#172>`_:
  Unable to set table column width on tables td's.
* `#151: <Kozea/WeasyPrint#151>`_:
  Table background colour bleeds beyond table cell boundaries.
* `#260: <Kozea/WeasyPrint#260>`_:
  TypeError: unsupported operand type(s) for +: 'float' and 'str'.
* `#288: <Kozea/WeasyPrint#288>`_:
  Unwanted line-breaks in bold text.
* `#286: <Kozea/WeasyPrint#286>`_:
  AttributeError: 'Namespace' object has no attribute 'attachments'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment