Skip to content
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

AssertionError assert align == 'end' when using Boostrap class table #1605

Closed
m-alorda opened this issue Mar 20, 2022 · 2 comments
Closed

AssertionError assert align == 'end' when using Boostrap class table #1605

m-alorda opened this issue Mar 20, 2022 · 2 comments

Comments

@m-alorda
Copy link

Error

I am getting the following error:

File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/inline.py", line 1143, in text_align
    assert align == 'end'
AssertionError

Just by using the table class from Bootstrap.

System Information

  • OS: alpine3.15
  • Python: 3.10.3
  • Weasyprint: 54.2
  • Bootstrap: 5.1.3

Minimal reproducible example

Example.html

<!DOCTYPE html>
<html>
  <head>
    <title>Example</title>
    <link
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
      rel="stylesheet"
      integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
      crossorigin="anonymous"
    />
  </head>
  <body>
    <table class="table">
      <tr>
        <th>Example</th>
      </tr>
    </table>
  </body>
</html>

test.py

from pathlib import Path

import weasyprint

CURR_DIR = Path(__file__).resolve().parent

html = weasyprint.HTML(filename=CURR_DIR / "example.html")
html.write_pdf(target=CURR_DIR / "example.pdf")

Whole stacktrace

Traceback (most recent call last):
  File "/workspaces/calendarFetcher/resources/test.py", line 9, in <module>
    html.write_pdf(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/__init__.py", line 183, in write_pdf
    self.render(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/__init__.py", line 134, in render
    return Document._render(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/document.py", line 930, in _render
    [Page(page_box) for page_box in page_boxes],
  File "/usr/local/lib/python3.10/site-packages/weasyprint/document.py", line 930, in <listcomp>
    [Page(page_box) for page_box in page_boxes],
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/__init__.py", line 133, in layout_document
    pages = list(make_all_pages(context, root_box, html, pages))
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/page.py", line 855, in make_all_pages
    page, resume_at = remake_page(i, context, root_box, html)
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/page.py", line 792, in remake_page
    page, resume_at, next_page = make_page(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/page.py", line 590, in make_page
    root_box, resume_at, next_page, _, _ = block_level_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 56, in block_level_layout
    return block_level_layout_switch(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 70, in block_level_layout_switch
    return block_box_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 112, in block_box_layout
    result = block_container_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 641, in block_container_layout
    next_page, new_children) = _in_flow_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 449, in _in_flow_layout
    collapsing_through) = block_level_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 56, in block_level_layout
    return block_level_layout_switch(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 70, in block_level_layout_switch
    return block_box_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 112, in block_box_layout
    result = block_container_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 641, in block_container_layout
    next_page, new_children) = _in_flow_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 449, in _in_flow_layout
    collapsing_through) = block_level_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 56, in block_level_layout
    return block_level_layout_switch(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 70, in block_level_layout_switch
    return block_box_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 112, in block_box_layout
    result = block_container_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 641, in block_container_layout
    next_page, new_children) = _in_flow_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 449, in _in_flow_layout
    collapsing_through) = block_level_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 56, in block_level_layout
    return block_level_layout_switch(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 66, in block_level_layout_switch
    return table_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/table.py", line 533, in table_layout
    all_groups_layout())
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/table.py", line 517, in all_groups_layout
    body_groups_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/table.py", line 381, in body_groups_layout
    new_group, resume_at, next_page = group_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/table.py", line 166, in group_layout
    new_cell, cell_resume_at, _, _, _ = block_container_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 631, in block_container_layout
    abort, stop, resume_at, position_y = _linebox_layout(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/block.py", line 304, in _linebox_layout
    for i, (line, resume_at) in enumerate(lines_iterator):
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/inline.py", line 43, in iter_line_boxes
    line, resume_at = get_next_linebox(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/inline.py", line 114, in get_next_linebox
    offset_x = text_align(
  File "/usr/local/lib/python3.10/site-packages/weasyprint/layout/inline.py", line 1143, in text_align
    assert align == 'end'
AssertionError
@m-alorda
Copy link
Author

This issue could be related to #1538, although its fix does not help with this issue.

@liZe
Copy link
Member

liZe commented Mar 20, 2022

Duplicate of #1586.

@liZe liZe closed this as completed Mar 20, 2022
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

No branches or pull requests

2 participants