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: Got ' /' between two lines. Expected nothing or a preserved line break #389

Closed
jstohner opened this issue Nov 17, 2016 · 1 comment
Labels
Milestone

Comments

@jstohner
Copy link

@jstohner jstohner commented Nov 17, 2016

This issue is similar, to #313, however I hope that I can provide enough information to reproduce the problem.

I get this error on the following HTML file (had to change the suffix to txt in order to embed in inside this issue):

crash-demo.html.txt

The crash is dependent on the selected font, i.e. WeasyPrint crashes if the font is DejaVu, but may not crash on other fonts. I am using WeasyPrint 0.31 on a CentOS 6.8 system with the standard DejaVu fonts:

shell$ weasyprint --version
WeasyPrint version 0.31
shell$ cat /etc/redhat-release 
CentOS release 6.8 (Final)
shell$ yum list installed | grep -i dejavu
dejavu-fonts-common.noarch          2.33-1.el6                         @base    
dejavu-sans-fonts.noarch            2.33-1.el6                         @base    
shell$

I think the problem is that WeasyPrint it trying to break the line after the / and not before it, which should be ok because it is a Unix file path. However I am afraid that this contradicts to "LB13" in the Unicode TR14 which is cited in line 716 of inlines.py. So you have to decide if it is a bug or a feature... :-)

Here is the Python 3 traceback:

shell$ weasyprint crash-demo.html crash-demo.html.pdf

Traceback (most recent call last):
  File "/usr/local/bin/weasyprint", line 11, in <module>
    load_entry_point('WeasyPrint==0.31', 'console_scripts', 'weasyprint')()
  File "/usr/local/lib/python3.5/site-packages/weasyprint/__main__.py", line 156, in main
    getattr(html, 'write_' + format_)(output, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/__init__.py", line 167, in write_pdf
    return self.render(stylesheets).write_pdf(target, zoom, attachments)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/__init__.py", line 135, in render
    return Document._render(self, stylesheets, enable_hinting)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/document.py", line 327, in _render
    return cls([Page(p, enable_hinting) for p in page_boxes],
  File "/usr/local/lib/python3.5/site-packages/weasyprint/document.py", line 327, in <listcomp>
    return cls([Page(p, enable_hinting) for p in page_boxes],
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/__init__.py", line 51, in layout_document
    pages = list(make_all_pages(context, root_box))
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/pages.py", line 562, in make_all_pages
    page_number)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/pages.py", line 514, in make_page
    positioned_boxes, positioned_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/blocks.py", line 69, in block_level_layout
    adjoining_margins)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/blocks.py", line 97, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/blocks.py", line 582, in block_container_layout
    adjoining_margins)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/blocks.py", line 69, in block_level_layout
    adjoining_margins)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/blocks.py", line 97, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/blocks.py", line 582, in block_container_layout
    adjoining_margins)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/blocks.py", line 69, in block_level_layout
    adjoining_margins)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/blocks.py", line 97, in block_box_layout
    page_is_empty, absolute_boxes, fixed_boxes, adjoining_margins)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/blocks.py", line 467, in block_container_layout
    for line, resume_at in lines_iterator:
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/inlines.py", line 48, in iter_line_boxes
    device_size, absolute_boxes, fixed_boxes)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/inlines.py", line 100, in get_next_linebox
    line_fixed, line_placeholders, waiting_floats)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/inlines.py", line 595, in split_inline_box
    waiting_floats)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/inlines.py", line 492, in split_inline_level
    context, box, max_x - position_x, max_x, skip)
  File "/usr/local/lib/python3.5/site-packages/weasyprint/layout/inlines.py", line 720, in split_text_box
    'Expected nothing or a preserved line break' % (between,))
AssertionError: Got ' /' between two lines. Expected nothing or a preserved line break
shell$ 

Thank you for providing WeasyPrint!

@liZe
Copy link
Member

@liZe liZe commented Nov 17, 2016

Thanks for reporting this bug once again, I can now reproduce it 🎉.

I work on this as soon as 0.32 is released (in 1 hour or so I hope).

@liZe liZe added bug crash labels Nov 17, 2016
@liZe liZe added this to the v0.33 milestone Nov 17, 2016
@liZe liZe closed this in 8cb093c Nov 22, 2016
jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Jan 15, 2017
Version 0.34
------------

Released on 2016-12-21.

Bug fixes:

* `#398 <https://github.com/Kozea/WeasyPrint/issues/398>`_:
  Honor the presentational_hints option for PDFs.
* `#399 <https://github.com/Kozea/WeasyPrint/pull/399>`_:
  Avoid CairoSVG-2.0.0rc* on Python 2.
* `#396 <https://github.com/Kozea/WeasyPrint/issues/396>`_:
  Correctly close files open by mkstemp.
* `#403 <https://github.com/Kozea/WeasyPrint/issues/403>`_:
  Cast the number of columns into int.
* Fix multi-page multi-columns and add related tests.


Version 0.33
------------

Released on 2016-11-28.

New features:

* `#393 <https://github.com/Kozea/WeasyPrint/issues/393>`_:
  Add tests on MacOS.
* `#370 <https://github.com/Kozea/WeasyPrint/issues/370>`_:
  Enable @font-face on MacOS.

Bug fixes:

* `#389 <https://github.com/Kozea/WeasyPrint/issues/389>`_:
  Always update resume_at when splitting lines.
* `#394 <https://github.com/Kozea/WeasyPrint/issues/394>`_:
  Don't build universal wheels.
* `#388 <https://github.com/Kozea/WeasyPrint/issues/388>`_:
  Fix logic when finishing block formatting context.


Version 0.32
------------

Released on 2016-11-17.

New features:

* `#28 <https://github.com/Kozea/WeasyPrint/issues/28>`_:
  Support @font-face on Linux.
* Support CSS fonts level 3 almost entirely, including OpenType features.
* `#253 <https://github.com/Kozea/WeasyPrint/issues/253>`_:
  Support presentational hints (optional).
* Support break-after, break-before and break-inside for pages and columns.
* `#384 <https://github.com/Kozea/WeasyPrint/issues/384>`_:
  Major performance boost.

Bux fixes:

* `#368 <https://github.com/Kozea/WeasyPrint/issues/368>`_:
  Respect white-space for shrink-to-fit.
* `#382 <https://github.com/Kozea/WeasyPrint/issues/382>`_:
  Fix the preferred width for column groups.
* Handle relative boxes in column-layout boxes.

Documentation:

* Add more and more documentation about Windows installation.
* `#355 <https://github.com/Kozea/WeasyPrint/issues/355>`_:
  Add fonts requirements for tests.


Version 0.31
------------

Released on 2016-08-28.

New features:

* `#124 <https://github.com/Kozea/WeasyPrint/issues/124>`_:
  Add MIME sniffing for images.
* `#60 <https://github.com/Kozea/WeasyPrint/issues/60>`_:
  CSS Multi-column Layout.
* `#197 <https://github.com/Kozea/WeasyPrint/pull/197>`_:
  Add hyphens at line breaks activated by a soft hyphen.

Bux fixes:

* `#132 <https://github.com/Kozea/WeasyPrint/pull/132>`_:
  Fix Python 3 compatibility on Windows.

Documentation:

* `#329 <https://github.com/Kozea/WeasyPrint/issues/329>`_:
  Add documentation about installation on Windows.


Version 0.30
------------

Released on 2016-07-18.

WeasyPrint now depends on html5lib-0.999999999.

Bux fixes:

* Fix Acid2
* `#325 <https://github.com/Kozea/WeasyPrint/issues/325>`_:
  Cutting lines is broken in page margin boxes.
* `#334 <https://github.com/Kozea/WeasyPrint/issues/334>`_:
  Newest html5lib 0.999999999 breaks rendering.


Version 0.29
------------

Released on 2016-06-17.

Bug fixes:

* `#263 <https://github.com/Kozea/WeasyPrint/pull/263>`_:
  Don't crash with floats with percents in positions.
* `#323 <https://github.com/Kozea/WeasyPrint/pull/323>`_:
  Fix CairoSVG 2.0 pre-release dependency in Python 2.x.


Version 0.28
------------

Released on 2016-05-16.

Bug fixes:

* `#189 <https://github.com/Kozea/WeasyPrint/issues/189>`_:
  ``white-space: nowrap`` still wraps on hyphens
* `#305 <https://github.com/Kozea/WeasyPrint/issues/305>`_:
  Fix crashes on some tables
* Don't crash when transform matrix isn't invertible
* Don't crash when rendering ratio-only SVG images
* Fix margins and borders on some tables


Version 0.27
------------

Released on 2016-04-08.

New features:

* `#295 <https://github.com/Kozea/WeasyPrint/pull/295>`_:
  Support the 'rem' unit.
* `#299 <https://github.com/Kozea/WeasyPrint/pull/299>`_:
  Enhance the support of SVG images.

Bug fixes:

* `#307 <https://github.com/Kozea/WeasyPrint/issues/307>`_:
  Fix the layout of cells larger than their tables.

Documentation:

* The website is now on GitHub Pages, the documentation is on Read the Docs.
* `#297 <https://github.com/Kozea/WeasyPrint/issues/297>`_:
  Rewrite the CSS chapter of the documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.