brechtm / rinohtype

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

More indexing woes... #381

Open techauthoruk opened 1 year ago

techauthoruk commented 1 year ago

Is there an existing issue for this?

PDF produced by rinohtype

With an index entry in a heading:

:index:`Safety instructions`
############################

in the table of contents, instead of the page number, I get 'XX'

image

Source files

See above. I can of course remove the index entry and place it in the body text. Not sure if this is an actual bug or a peculiarity of my installation.

Versions

rinohtype 0.5.5 (in development)
Sphinx 6.0.0b3
Python 3.10.6 (main, Aug 10 2022, 11:40:04) [GCC 11.3.0]
Linux-5.10.16.3-microsoft-standard-WSL2-x86_64-with-glibc2.35
techauthoruk commented 1 year ago

Ah, this only happens in one instance. When 'XX' is displayed in the ToC, it only happens where there is link directly above the heading:

.. _Prepare:

:index:`Preparing` the |prodname| for use
#########################################
techauthoruk commented 1 year ago

Actually, it seems any directive before the heading causes this issue, for example:

.. raw:: html
...

@brechtm is this a rinoh issue or something particular to my install?

brechtm commented 1 year ago

The XX basically means that rinohtype can't resolve the reference or page number. I'll need to investigate to see what's happening exactly. Thanks for the extra info!

brechtm commented 1 year ago

I can't reproduce this (tests-regression/sphinx/test-ref/chapter1.rst - project zip). It could also be a Sphinx bug that's already fixed (I tried with 5.3.0). If you still see this with Sphinx 5.3.0, please provide a minimal Sphinx project triggering the bug.

techauthoruk commented 1 year ago

This occurs with Sphinx version 6.0.0b3 - I will retest with 5.3 and let you know the results

techauthoruk commented 1 year ago

Same thing happens with Sphinx 5.3:

image

Do you want me to send my demo instance?

brechtm commented 1 year ago

Do you want me to send my demo instance?

Yes, please.

techauthoruk commented 1 year ago

OK...here it is. Bear in mind this is the content I was using for the pdf rear page development, so its a bit all over the place. However, I have edited the hands.rst file to add an index entry:

.. _Prepare:

:index:`Preparing` the |prodname| for use
#########################################

test text

General health and safety
#########################

Hope this helps!

pdf-dev.zip

brechtm commented 1 year ago

Thanks, that helped! Turns out this only happens with index terms in section titles that are rendered out of line (_BodyPageTemplate.chapter_titleflowables). For the book template (and your derivative), that means chapter titles. In some cases, it does output a page number, possibly a wrong one, and the hyperlink is broken. Not yet sure how to fix this...

techauthoruk commented 1 year ago

Now I'm aware of the issue, it isn't a problem (I will not add an index entry to a heading where there is a directive preceding it), but if you can find a fix, that would be great (as I am bound to forget about this!)

brechtm commented 1 year ago

I will not add an index entry to a heading where there is a directive preceding it

To be clear: the issue isn't caused by the directive preceding it. It happens when the index role is used in a chapter title. This is because chapter titles are rendered in a different way (in the Book template, at least).