rstudio / pagedown

Paginate the HTML Output of R Markdown with CSS for Print
https://pagedown.rbind.io
Other
892 stars 129 forks source link

code_folding? #90

Open ignacio82 opened 5 years ago

ignacio82 commented 5 years ago

Is there any plan to add a code_folding option to pagedown::html_paged: ? I tried the following but it did not work as expected:

output:
  pagedown::html_paged:
    theme: default
    code_folding: hide
    toc: false
    # change to true for a self-contained document, but it'll be a litte slower for Pandoc to render
    self_contained: true
yihui commented 5 years ago

Sorry, but no. The main goal of pagedown is for printing. You cannot fold code on paper, so it is unlikely that we will support code-folding in pagedown.

RLesur commented 5 years ago

I agree: the goal of pagedown is to paginate a document using web technologies. The main difference with a html document is that pages have a limited available height (a web page has no vertical constraint).

pagedown::html_paged() uses Paged.js as a rendering engine. Once rendered, we cannot change the content height without breaking the document. The main problem is that the current implementation of code_folding in rmarkdown::html_document() modifies the content height.

With respect to this constraint on the content height, it is possible to add some interactivity to a paged html document: the reader could interact with the content before printing it. The main risk is that the printed content differs from one user to the other depending on the actions performed on the paged html document (this might lead to a reproducibility issue). However, I recognize that interacting with a paged document before printing it can be really fun and creative.