ggrossetie / asciidoctor-web-pdf

Convert AsciiDoc documents to PDF using web technologies
https://asciidoctor.org
MIT License
445 stars 92 forks source link

Table of Contents is missing from the PDF outline #534

Open vishalkrsinha opened 3 years ago

vishalkrsinha commented 3 years ago
:doctype: book
:PubDate: October 2020
:SystemType: Eductor
:KSDocType: Module Reference

= {SystemType}
ifdef::backend-pdf[]
:toc: macro
endif::[]

:sectnums:
:experimental:
:RevNumber: B
:icons: font
:linkattrs:
:webfonts!:
:data-uri:
:linkcss:
:iconfont-remote!:
:webfonts!:
:stylesdir: ../../../../../DocResources/css

<<<

*Document history*

[cols="12,15,73"]
|===
3+|{set:cellbgcolor:#ccc}
|{set:cellbgcolor:}Rev. A
|March 2013
|Created document and first XML version -- MHy
|Rev. B
|October 2020
|Design calculations -- MHy

|===

ifdef::backend-pdf[]
toc::[]
endif::[]

== Introduction
....

Above script generates proper toc with 'asciidoctor-pdf' as below... toc-asciidoctor-pdf

But the same script doesn't generate the toc at all with 'asciidoctor-web-pdf' as below... toc-asciidoctor-web-pdf

Suggestions to correct this will be much appreciated. Thank you.

ggrossetie commented 3 years ago

backend-pdf is not defined in this converter, see: https://github.com/Mogztter/asciidoctor-web-pdf/issues/129

So both conditional blocks won't work:

ifdef::backend-pdf[]
:toc: macro
endif::[]

// ...

ifdef::backend-pdf[]
toc::[]
endif::[]

You can use env-web-pdf or pass a custom attribute.

vishalkrsinha commented 3 years ago

env-web-pdf

Sorry, but got confused with the suggestion(s) here. I modified my script a bit as below (just commented out the conditional parts):

:doctype: book
:PubDate: October 2020
:SystemType: Eductor
:KSDocType: Module Reference

= {SystemType}
// ifdef::env-github[]
:toc: macro
:toclevels: 3
// endif::[]

:sectnums:
:experimental:
:RevNumber: B
:icons: font
:linkattrs:
:webfonts!:
:data-uri:
:linkcss:
:iconfont-remote!:
:webfonts!:

<<<

*Document history*

[cols="12,15,73"]
|===
3+|{set:cellbgcolor:#ccc}
|{set:cellbgcolor:}Rev. A
|March 2013
|Created document and first XML version -- MHy
|Rev. B
|October 2020
|Design calculations -- MHy

|===

// ifdef::env-github[]
// toc::[]                          
// endif::[]

== Introduction

And I see the below output - No toc on the left side (in bookmarks) but see on the right side: toc

I need toc in Bookmark section too with numbering of contents exactly similar to 'asciidoctor-pdf' results. Suggestions please?

PS: I see html & pdf both files getting generated here instead of just the 'pdf'.

ggrossetie commented 3 years ago

Oh I see, so the Table Of Contents is generated but missing from the PDF outline right?

Probably something we need to fix to be "on par" with asciidoctor-pdf.

vishalkrsinha commented 3 years ago

Oh I see, so the Table Of Contents is generated but missing from the PDF outline right?

Yes. But I believe toc would have been in bookmarks (left pane are) too along with in main document. I might be missing the trick. Do you have any simplest example please for the same?

Probably something we need to fix to be "on par" with asciidoctor-pdf.

vishalkrsinha commented 3 years ago

Any update please?

ggrossetie commented 3 years ago

Any update please?

This is an open source project, if you want to implement this feature, you will need to update the logic in here: https://github.com/Mogztter/asciidoctor-web-pdf/blob/main/lib/outline.js