ggrossetie / asciidoctor-web-pdf

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

:showtitle!: is not respected #547

Open michaelsauter opened 3 years ago

michaelsauter commented 3 years ago

I have the following .adoc file:

= Deployment Instructions
:showtitle!:
:sectnums:
:toc: macro

Paragraph content

However, when I run asciidoctor-web-pdf mydoc.adoc, the resulting PDF contains the document title. Is disabling this not supported?

→ asciidoctor-web-pdf --version
Asciidoctor Web PDF 1.0.0-alpha.12 using Asciidoctor.js 2.2.1 (Asciidoctor 2.0.12) [https://asciidoctor.org]
Runtime Environment (node v12.18.1 on darwin)
CLI version 3.4.0
ggrossetie commented 3 years ago

That's correct, currently the document title is always shown. For reference, we should check if doc.hasHeader() && !doc.getNotitle() in:

https://github.com/Mogztter/asciidoctor-web-pdf/blob/339b485188e797a2fe88d025bba005e1751f87ab/lib/document/document-converter.js#L485-L499

Feel free to open a pull request to implement this feature.

michaelsauter commented 3 years ago

What would the correct logic be? Should node.getDocumentTitle() be hidden, but the author shown if there is a title page?

ggrossetie commented 3 years ago

What would the correct logic be? Should node.getDocumentTitle() be hidden, but the author shown if there is a title page?

@michaelsauter That's a good question and still something we need to agree on: https://github.com/asciidoctor/asciidoctor/issues/4011

To answer your question, I personally think we should show the header (author + revision) when there's a header, noheader is false and notitle is true. You can check this table for all the combinations: https://github.com/asciidoctor/asciidoctor/pull/3979#discussion_r600520281

Alternatively, we could mimic what Asciidoctor PDF (https://github.com/asciidoctor/asciidoctor-pdf) is doing. Apparently, when :!showtitle: is defined, Asciidoctor PDF won't generate a title page even when there are author(s) and/or revision(s).

@mojavelinux Any thoughts?

michaelsauter commented 3 years ago

Alternatively, we could mimic what Asciidoctor PDF (https://github.com/asciidoctor/asciidoctor-pdf) is doing. Apparently, when :!showtitle: is defined, Asciidoctor PDF won't generate a title page even when there are author(s) and/or revision(s).

This makes sense to me - not sure if "right" but I would think a title page without title does not make too much sense.

ggrossetie commented 3 years ago

This makes sense to me - not sure if "right" but I would think a title page without title does not make too much sense.

I agree but it can make sense when you are printing an article where you might to show the author and revision (even if the document title is hidden). For instance:

image

michaelsauter commented 2 years ago

@Mogztter @mojavelinux any update on how this should be implemented?

zebreus commented 1 year ago

I currently use the following JavaScript in the document as a workaround to remove the title page.

// Remove title page
++++
<script>
    var titlePageElement = document.getElementById("cover");
    titlePageElement?.parentNode.removeChild(titlePageElement);
</script>
++++