Openscapes / series

Lesson series for the Openscapes Champions program
http://openscapes.github.io/series
Creative Commons Attribution 4.0 International
11 stars 16 forks source link

Add pdf output option #44

Closed stefaniebutland closed 1 month ago

stefaniebutland commented 3 months ago

adding format: pdf: default to _quarto.yml resulted in pdf of only index.qmd on my first try. Cool that it adds "pdf" button to home page.

Noting attempt here.

format:
  html:
    theme:
      light: [cosmo, theme.scss] # from https://github.com/sta210-s22/website/blob/main/_quarto.yml
      dark: [cosmo, theme-dark.scss]
    mainfont: "Atkinson Hyperlegible"
    code-copy: true
    code-overflow: wrap
    toc: true
  pdf: default    

Screenshot 2024-06-15 at 3 42 45 PM

Output

hyperlinks worked, but links to filename.qmd were linked to that filename, not the html

Screenshot 2024-06-15 at 4 04 30 PM

stefaniebutland commented 3 months ago

How to turn whole site to pdf? Searching

Typst available in Quarto 1.4:

Typst is a new open-source markup-based typesetting system that is designed to be as powerful as LaTeX while being much easier to learn and use. Typst creates beautiful PDF output with blazing fast render times.

The following also gave only homepage content and did not include hyperlinks

  typst:
    toc: true
    number-sections: true
stefaniebutland commented 3 months ago

Comments from posit/ quarto team in 2023 indicate we can pdf a book but not a website Is it possible to print your whole website to PDFs? #5782

jules32 commented 3 months ago

This is great sleuthing Stef, thanks. Yes for the Reflections Booklet, we had to make the project a Book, not a Website. I'll ask Andy about options for current website-to-pdf workarounds vs changing Series to a Book.

ateucher commented 3 months ago

@jules32 the main barrier to converting the site to a book (which is the cleanest way to do this), is the three-level hierarchy (Core Lessons > GitHub Strategies > GitHub for Publishing). Books only allow two levels (Part > Chapter), so we would have to "flatten" that section to two levels...

jules32 commented 3 months ago

Thanks @ateucher ! I've just merged and we can test to see how it looks

jules32 commented 3 months ago

I've merged my branch with edits, so when @ateucher you're able to implement in Main, all my updates will be there. Thank you!

ateucher commented 3 months ago

I opted not to convert to a book, rather included a file _make_pdf.qmd that compiles a pdf.

Closed by #54

jules32 commented 2 months ago

Hi @ateucher ,

I noticed that the publish date was wrong so I fixed it to today's date and pushed, which updated the date on the html book. But I can't seem to update the PDF's date. I've tried via web browser (GitHub Action build) and also by running locally. When I tried running locally following the GitHub Action's code L29, I get this error:

JLos-MacBook-Pro:series jlo$ quarto::quarto_render("_make_pdf.qmd")
bash: syntax error near unexpected token `"_make_pdf.qmd"'

Do you mind having a look and updating the PDF? Thank you!

jules32 commented 2 months ago

Following up @ateucher -

I realized I needed to also fix today's date in the _make_pdf.qmd file as well. The GitHub Action has now created a PDF with today's date.

Could you please still look into how to create the local build, and update the README with how to build the PDF locally? Thank you!

ateucher commented 2 months ago

Nice, I didn't know about the last-modified quarto keyword (https://github.com/Openscapes/series/commit/ce9685d995f251daf0b6b64f87eb611444a1263f). I wonder if it should be today instead though? last-modified might not get updated if the constituent pages get updated but not _make_pdf.qmd itself?

jules32 commented 2 months ago

Ah yes please update to today if that is the best current approach! Is there a way to delete it from the _make_pdf.qmd so that it only appears in one place, on the root index.qmd?

ateucher commented 2 months ago

Not easily I don't think. But just saw this: https://github.com/quarto-dev/quarto-cli/issues/5967. Basically last-modified relies on the timestamp on your computer, so will always give today's date in GitHub Actions - basically the same behaviour as today :). I think the most straightforward is to just set today in both places... they should then always match since they're rendered at the same time in GitHub Actions

jules32 commented 2 months ago

Sounds like a good plan!

ateucher commented 1 month ago

Continuing in #56