brechtm / rinohtype

The Python document processor
http://www.mos6581.org/rinohtype
GNU Affero General Public License v3.0
498 stars 59 forks source link

Zero width spaces lead to an attribute error #415

Closed jwhitham closed 11 months ago

jwhitham commented 1 year ago

Is there an existing issue for this?

Sphinx or rinoh output

Running Sphinx v7.0.1
c:\doctools\.venv\lib\site-packages\rinoh\resource.py:44: UserWarning: The stylesheet 'sphinx' is also provided by:
* rinohtype
Using the one from 'rinohtype'
  warn("The {} '{}' is also provided by:\n".format(cls.resource_type,
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
writing output...
building [rinoh]: all documents
updating environment: 0 added, 1 changed, 0 removed
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
processing target... index resolving references...
c:\doctools\.venv\lib\site-packages\rinoh\resource.py:44: UserWarning: The template 'book' is also provided by:
* rinohtype
Using the one from 'rinohtype'
  warn("The {} '{}' is also provided by:\n".format(cls.resource_type,
rinohtype 0.5.4 (2022-06-17)  Copyright (c) Brecht Machiels and contributors
This program comes with ABSOLUTELY NO WARRANTY. Its use is subject
to the terms of the GNU Affero General Public License version 3.
rendering...
References cache read from C:\doctools\build\rinoh\target.rtc
TeX Gyre Pagella does not include a normal medium upright font. Falling back to normal regular upright

Exception occurred:
  File "c:\doctools\.venv\lib\site-packages\rinoh\paragraph.py", line 831, in render
    for first, second in word.hyphenate(container):
AttributeError: 'ZeroWidthSpace' object has no attribute 'hyphenate'

Source files

zero-width-spaces-attribute-error-2.zip

The bug can be reproduced by running "demo.bat".

Based on suggestions in https://github.com/brechtm/rinohtype/issues/188 , I have attempted to help Rinoh split up the long "word" that you can see in index.rst, "/EXAMPLE/DEMO/EXAMPLE/DEMO" by adding zero-width spaces after each / character. Unfortunately this leads to the AttributeError. I found that adding a dummy "hyphenate" method in paragraph.ZeroWidthSpaces would fix it.

The latest version from Github, commit b7be22f, also appears to have this problem.

Versions

c:\doctools\.venv\lib\site-packages\rinoh\resource.py:44: UserWarning: The stylesheet 'sphinx' is also provided by:
* rinohtype
Using the one from 'rinohtype'
  warn("The {} '{}' is also provided by:\n".format(cls.resource_type,
rinohtype 0.5.4 (2022-06-17)
Sphinx 7.0.1
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)]
Windows-10-10.0.19041-SP0