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
Listings break book PDFs/EPUBs without any warning #7699
Comments
My original listing page was with |
I guess in most cases it's reasonable that listings as used, for example, for blogs are not valid for books, but then that makes the statement that books "support all of the same features as websites" questionable. In my case, the I wondered if I could suppress the listing by giving it an
but that still produces a broken PDF. |
Websites are not So, if you want to use that, use conditional content to not include an HTML feature in I am going ahead and closing this, as it is not a bug but rather a misuse of the feature depending of the formats. |
I'm new to Quarto. I was very happy with some content as a website (originally rendered with Docusaurus), but we identified that some users might benefit from the entire thing as a PDF or EPUB, so I was just hoping that converting to a book would be a reasonable means to achieve that. I missed the point that 'HTML books' are not guaranteed to be PDF-able. |
I perfectly understand the use case but many HTML features will never come to PDF because the tools are too much different, thus the conditional content feature which allow user to use |
Be that as it may, Quarto should strive to never generate malformed content. A few options:
|
Thank you @cscheid - I was intending to come back this morning and appeal that simply getting a bad PDF without warning is pretty unhelpful. I also found #5782 touches on some of the same things. You might also see that I did try to get the listing content within a |
What you did is completely reasonable, but doesn't solve the bug: the Two things happen when you add listings: the listing contents itself, and all of the HTML dependencies of the listing contents that we have to add. The One can argue that the "HTML detritus" of the listings feature sticking around when |
In other SSG's (well, mainly Mkdocs) before I recently landed here (and was greatly impressed with the maturity of the approach) I'd resorted to simply adding a script with suitable Pandoc commands to generate whichever set of source files into a PDF or EPUB, so I'm not averse to reverting to that. I'm trying to wean people off even thinking about needing such things for the use case I have, so was hoping not to put any/much effort into this - but I certainly appreciate the discussion here. |
Then the issue is way more general than PDF/EPUB as Typst, Word, etc are likely to be affected as well, and possibly other HTML-based features in Quarto behave like listings. |
Being a novice here (at least with respect to Quarto, if not SSGs, structuring of source projects, YAML etc), might I just describe what might be my ideal solution? I'd be very happy to stay with The way of specifying the I have no idea if that's easier to contemplate within the constraints of the implementation... it's just a suggestion. |
We'd like to support that as well, but "composite PDF" formats is, as of today, just "book through the LaTeX toolchain". That format is stricter than I'll note that if you use a "book" project, you still get a "website" and you can get a PDF composite. Your website, of course, will have some limitations in the format, but many books have been written and published this way: https://quarto.org/docs/books/index.html |
@cscheid - that's fine, and it was the temptation saying that "ah, if people really want a pdf of the collection of material then that's really a book" which was the beginning of this, but I ran myself into the wall of the differences between the types. I will stick with |
Sorry if I'm labouring a point here, but I just changed the
this gives me an |
Thank you. |
Thanks for the detailed reporting - I'm sorry to say that when I try to reproduce the issue, I'm not able to (as I would expect, knowing how listings work). Listing process is tied directly to HTML output - when a PDF is being generated no code runs which processes listings, so they are ignored. I confirmed this by creating a default book project and the modifying the index.qmd to contain a listing of various formats that you suggested. In all cases, I was able to properly render and view a I've attached a zip of my attempt to reproduce the issue (including the outputs). If you are able to consistently reproduce this issue, it would be great if you could provide the complete reproducible case so I can test locally - it will be very unexpected if listing content is ending upon in PDF output! |
@dragonstyle ... well, this is interesting/embarrassing - I unzipped your archive and checked my Mac could open the generated PDF and all was fine. However if I rebuild it with So the problem is with my Mac's stack of software... what I don't know. Surely this would just be down to my version of Quarto and TinyTex? Does:
tell you anything suspicious? |
You could try to use Quarto to remove and reinstall TinyTex. |
That log output seems completely fine - You might want to try a simple document as a PDF and see whether that works (e.g. standalone document like): ---
title: Hello World
format: pdf
---
## Hello World
This is a PDF If that renders fine, then perhaps there is something about books triggering this that differs between our environments. One other useful thing to do would be to include the option Generally if we were making invalid LaTeX, I would expect an error while rendering the LaTeX to PDF (for example if we mixed HTML and LaTeX), so this is unusual for sure. Can you share one of these broken pdfs and we can see if I can open it? |
I can confirm that on my machine the first is broken (though not in some obvious way, sadly), and the second is not... Could you share the exact project that is reproducing this? Alternatively, can you trying using |
contains the tex which gives the broken PDF. |
I've been doing all this this evening just modifying the copy of the project which you sent me in the book.zip earlier. |
I'm perplexed. When I render that I can't explain how the presence of the |
We must be looking in the wrong place.... here are If the .tex files are actually the same, there must be something else downstream of that which breaks the PDF. But I have also, belatedly, noticed that the broken
whereas, perhaps obviously, the good case where there's no presentation of front-matter with |
And, yes - |
This ZIP has a |
May I suggest to use a Git repository instead of many zip archives? |
I can reproduce it locally (woo hoo!) - the key is to use the command |
Progress!
|
Ok that was pretty straightforward- there are I'll start a fresh pre-release build and this should be testable within a 10-15 minutes. Once again thx for persistence this was a good that defied my expectations! |
@dragonstyle - that's great - many thanks! |
hmm... @dragonstyle - did you test this for epubs as well as pdfs? |
I didn't text the mixed render case :( - will check now! |
I added:
to _quarto.yml and got an epub out but it didn't open with Macos 'Books' app (whereas other epubs from Quarto without |
Yeah, it was the same problem - I needed the check to be even more strict. A fresh build is on the way! |
Many thanks! |
Bug description
I was turning a website into a book and struggled to understand why Quarto (1.4 as it happens) was producing PDFs and EPUBs which Macos Preview refuses to open with the complaint that the file is broken or an invalid format.
I finally discovered that removing the
listing
options fromindex.qmd
would give me a working PDF and EPUB.Searching got me as far as the Discussion #4266 where it's stated that listings are only supported for websites. But with https://quarto.org/docs/books/ saying:
and the listing working for the html of the website of the book, I think there's at least a doc update needed - I couldn't find any qualification that listings don't work with PDF/EPUBs of books, but also this should perhaps be diagnosed during
quarto render
so people don't scratch there heads as much.Apologies if I've missed a statement in the docs.
Steps to reproduce
I've reproduced by using the boilerplate book project and making the
index.qmd
a listing page thus:Expected behavior
Preview gives me HTML as expected:
Actual behavior
but the PDF is unusable
Your environment
Quarto 1.4
Macos Sonoma 14.1.1
Quarto check output
The text was updated successfully, but these errors were encountered: