Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document title is redundant with cover #1066

Open
CendioOssman opened this issue Mar 21, 2022 · 2 comments
Open

Document title is redundant with cover #1066

CendioOssman opened this issue Mar 21, 2022 · 2 comments

Comments

@CendioOssman
Copy link

The main title of the document is generally included in the cover page, so you don't want it again at the start of the actual contents.

This also causes everything in the document structure to jump one level down, with the document title as a new top node including everything.

Description of problem
A simple document like this:

Main title
==========

Intro
-----
Lots of text

In the PDF I then get a cover page with "Main title", then on the first page we get "Main title" again.

What is the expected output? What do you see instead?
The body of the document should start with "Intro".

🖥 Versions
python -V: 3.6.12

pip freeze | grep rst2pdf: 0.98

pip freeze | grep reportlab: 3.6.1

pip freeze | grep Sphinx: 4.2.0

Which operating system are you using?

Linux

Additional information

If I compare things with Sphinx' LaTeX based PDF generator it omits this top level structure node. I've written a Sphinx extension that does the same for rst2pdf:

#
# Extension that removes the top level section wrapper
#

from sphinx.transforms.post_transforms import SphinxPostTransform

class PDFNoTitleTransform(SphinxPostTransform):
    default_priority = 600

    def is_supported(self):
        return self.app.builder.name == "pdf"

    def run(self):
        self.document.replace(self.document[0], self.document[0][1:])

def setup(app):
    app.add_post_transform(PDFNoTitleTransform)

    return { "parallel_read_safe": True,
             "parallel_write_safe": True }
@lornajane
Copy link
Contributor

Ah, I can totally see how that could be unnecessary but since the document and the cover page are independent, I'm not sure what change we can make to rst2pdf itself that would make sense for this use case as well as any/all other use cases. In our case, I'm not sure it's a bug, but more like that the documents should be fed to rst2pdf already designed to be used together; in which case your sphinx extension is a pretty nice solution. Thanks for sharing!

Do you think there's more we can do on this issue that would work for all users?

@CendioOssman
Copy link
Author

I think so, yes. I suspect many will do what we did, and that is to replace Sphinx' LaTeX based PDF builder, with rst2pdf. As such, we (and likely others) expected a similar behaviour from rst2pdf. Since the Sphinx source needs to work for multiple builders, it can't really be adapted for just rst2pdf.

I agree that this should probably not be in the general rst2pdf. But I think it should be in the pdfbuilder Sphinx module. That's what suppose to handle the bridging of Sphinx and rst2pdf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants