asciidoctor / asciidoctor-pdf

:page_with_curl: Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
https://docs.asciidoctor.org/pdf-converter/latest/
MIT License
1.14k stars 500 forks source link

Index section with no terms swallows next section #2368

Closed georgeraraujo closed 1 year ago

georgeraraujo commented 1 year ago

Versions:

$ asciidoctor-pdf --version
Asciidoctor PDF 2.3.3 using Asciidoctor 2.0.18 [https://asciidoctor.org]
Runtime Environment (ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)

Source, with commented index terms:

= Sample book with index section, but no index terms
Author
:doctype: book
:nofooter:
:toc: left

[[chapter-one]]
== Chapter one

// indexterm2:[Lancelot] was one of the Knights of the Round Table.
// indexterm:[knight, Knight of the Round Table, Lancelot]

[[the-index]]
[index]
== Index

[[the-glossary]]
[glossary]
== Glossary

[[the-bibliography]]
[bibliography]
== Bibliography

[[the-colophon]]
[colophon]
== Colophon

Output: index-with-no-terms.pdf

The TOC does not show the index section, nor the PDF has it. The TOC shows the Glossary section, but the PDF does not have it, and its page shows up as ? in the TOC page.

Now with the index terms uncommented:

= Sample book with index section, and with index terms
Author
:doctype: book
:nofooter:
:toc: left

[[chapter-one]]
== Chapter one

indexterm2:[Lancelot] was one of the Knights of the Round Table.
indexterm:[knight, Knight of the Round Table, Lancelot]

[[the-index]]
[index]
== Index

[[the-glossary]]
[glossary]
== Glossary

[[the-bibliography]]
[bibliography]
== Bibliography

[[the-colophon]]
[colophon]
== Colophon

Output: index-with-terms.pdf

The TOC shows the index section, and the PDF has it. The TOC shows the Glossary section, the PDF has it, and its page shows up correctly in the TOC page.

georgeraraujo commented 1 year ago

I just tested with 2.3.4, and the result is the same.

mojavelinux commented 1 year ago

I can confirm this bug. When the index section is removed, it affects the iteration over the sibling blocks. A different strategy will be needed.