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 501 forks source link

Headings marked as index item does not put text in PDF outline items #2430

Closed cdokolas closed 1 year ago

cdokolas commented 1 year ago

I'm marking headers as index items (non-concealed) and I noticed that the PDF outline now has blank section items (untitled).

I'm using current asciidoctor-pdf and all gems freshly updated on Windows 11. Also, section-refsig and chapter-refsig have been unset.

There is a workaround, making the header names normal and duplicating them as concealed index items, but this must be a bug none the less.

mojavelinux commented 1 year ago

This is not the behavior I observe. I expect that the outline will use the text from the non-concealed index term.

Please provide a concrete example that I can test, as it may provide details that you are not mentioning that are affecting the behavior. Also, please report which version of Asciidoctor PDF you are using (asciidoctor-pdf -v).

cdokolas commented 1 year ago

Hope this helps...

Asciidoctor PDF 2.3.7 using Asciidoctor 2.0.20 [https://asciidoctor.org]
Runtime Environment (ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x64-mingw-ucrt]) (lc:IBM437 fs:UTF-8 in:UTF-8 ex:UTF-8)

Sample document:

= PDF Outline Bug Reproduction
:doctype: book
:outlinelevels: 4:1
:sectnums:

== ((This is a Chapter))

This is Chapter 1.

=== ((This is a Section))

==== ((This is a Sub-Section))

Command used to convert: asciidoctor-pdf -t -b pdf -o "outline.pdf" "outline.adoc"

Keep up the good work!

mojavelinux commented 1 year ago

The nuance is that this seems to happen when sectnums is enabled, which is rather surprising. I'll take a closer look.

mojavelinux commented 1 year ago

FYI, -b pdf is redundant when using the asciidoctor-pdf command.

mojavelinux commented 1 year ago

This appears to be a bug in either Prawn or the PDF format. When there's a null character in the value of an outline, it stops showing the text after that point. We'll have to remove the null character (which is used internally as a placeholder for the index term).

mojavelinux commented 1 year ago

The null character is making it to the PDF, so it must be the PDF reader that's tripping up on it.

In fact, it may even be a limitation of evince (or whatever it's built on). I don't see the same issue when using the Firefox PDF viewer.

mojavelinux commented 1 year ago

I'll backport this to the v2.3.x release line.