renderthis icon indicating copy to clipboard operation
renderthis copied to clipboard

Can't render a qmd presentation

Open giabaio opened this issue 1 year ago • 15 comments

Hi all, I have a qmd/revealjs presentation, but I have customised the theme and have created a template. The slides compile perfectly, but when I try to pdf them using renderthis I get a message

Error in to_pdf_complex(path_from(step_html, "url"), output_file, partial_slides,  : 
  Input does not appear to be xaringan or quarto slides:

I think this gets triggered by the check in

has_remark <- b$Runtime$evaluate("typeof slideshow !== 'undefined'")$result$value
  if (!has_remark) {
    stop("Input does not appear to be xaringan or quarto slides: ", input)
  }

Not sure how to deal with this though...

I'm testing this on a html file output by quarto both locally and deployed online (https://giabaio.github.io/test-quarto). Sorry if I'm missing an obvious point!

Thanks for your help! Gianluca

giabaio avatar Aug 03 '22 09:08 giabaio

Sorry to come back to this, but does anybody have some more insight into this? The qmd presentation gets parsed OK (a bit worse than what was happening for xaringan slides, I think...) onto pdf, if I don't use the complex_slides/partial_slides options, but it still fails otherwise...

(I appreciate the summer has got in the way --- and people have way better things to do than obsessively look at the issues on their GitHub repo!... :-)) Thanks! Gianluca

giabaio avatar Sep 06 '22 15:09 giabaio

We've been dealing with other issues trying to get the package on CRAN. It was just removed from CRAN yesterday due to a remaining obscure note in the checks that we have yet to solve. Our current plan for further development is to get this back on CRAN, then add support for handouts, then start working on Quarto support. So eventually we'll get to this. I suspect there are several things we will need to change to get Quarto slides more properly supported.

jhelvy avatar Sep 06 '22 15:09 jhelvy

Thank you, @jhelvy! Like I said, I appreciate that life gets in the way and dealing with repos is way more work than you bargain for, when you set it up!... :-)

giabaio avatar Sep 06 '22 16:09 giabaio

In the medium term:

  1. Render your slides using the Render button or quarto render.
  2. Apply renderthis::to_pdf() to the rendered html: renderthis::to_pdf("slides.html")
  3. The default to_pdf() should work, but note that you cannot enable complex_slides or partial_slides since those are both tightly coupled to xaringan slides.

gadenbuie avatar Sep 06 '22 16:09 gadenbuie

Thanks, @gadenbuie --- yes: that more or less works (like I said, slightly worse than what was happening for xaringan slides, but that will do!).

giabaio avatar Sep 06 '22 17:09 giabaio

This should (hopefully) be resolved now with v0.2.0 now on CRAN.

jhelvy avatar Sep 29 '22 15:09 jhelvy

Thank you. It does plough through (without complex or partial slides, as @gadenbuie said) and it does OK-ish... It struggles, I think, when the underlying quarto file has too much customisation/added components? See if these two (relatively manipulated and restructured qmd/css files) help debug?

I think some issues may be quarto-related quirks that don't directly affect xaringan... Happy to help (if I can...).

giabaio avatar Sep 29 '22 17:09 giabaio

Yeah it shouldn't be any different from opening the Quarto slides in Chrome and printing to PDF. If you see discrepancies between to_pdf() and manual printing in Chrome, it might be our fault (or we might be able to fix it). In places where the output is the same but not what you want, your best bet is to report it to Quarto.

gadenbuie avatar Sep 30 '22 22:09 gadenbuie

Yes. I think Chrome would give the same output as to_pdf so that's a quarto quirk... It renders very well to pdf when the slides are fairly basic (and don't deviate from the default revaljs structure, I think...). My slides have a heavily customised title page (which struggles to render properly) and some other features produce empty pages etc...

All in all, I think this is a part where xaringan still does better in terms of then rendering to pdf. But thanks for your awesome work!

giabaio avatar Oct 01 '22 07:10 giabaio

Maybe try to set the "suffix" ?print-pdf, e.g., my-file.html?print-pdf (see https://revealjs.com/pdf-export/). This is what pagedown is using, thus what renderthis is using.

mcanouil avatar Nov 03 '22 20:11 mcanouil

mmm... Not sure I am making this wrong, but if I try renderthis::to_pdf("https://gianluca.statistica.it/slides/ispor-2022/bcea/index.html?print-pdf",to="slides.pdf",complex_slides = T,partial_slides = T) I get Error: from must have extension: .rmd, .qmd

Can you please clarify what you mean @mcanouil? Thanks!

giabaio avatar Nov 03 '22 20:11 giabaio

When you use Chrome, add the ?print-pdf in the URL, because pagedown is basically doing that (i.e., no need of ?print-pdf inside a call to renderthis or pagedown::chrome_print()).

mcanouil avatar Nov 03 '22 20:11 mcanouil

Thank you. I've tried with this https://gianluca.statistica.it/slides/ispor-2022/bcea/index.html?print-pdf but the results aren't great... Some of the pages render OK, but others are just rendered as blank pages or worse...

giabaio avatar Nov 04 '22 09:11 giabaio

I think the advice being offered is mostly around what's possible in terms of printing to PDF. If the slides don't look great when printing to PDF from Chrome, then that's a problem with the framework being used to create the slides — renderthis doesn't (and can't) do much more than coordinate printing via Chrome. So even more concretely, if your Quarto or xaringan slides don't look great when you print them in Chrome, please report those problems in the Quarto or xaringan repos.

gadenbuie avatar Nov 14 '22 16:11 gadenbuie

Thank you, @gadenbuie - I think xaringan doesn't have any issues (at least with my own template) and the printing-to-pdf (via renderthis or manual) is pretty solid... My quarto template struggles and, like you say, it's probably an issue with how quarto handles some customisation...

Thank you all for looking into this! Appreciate it! :pray:

giabaio avatar Nov 14 '22 17:11 giabaio