Open ronbactawar opened 3 years ago
I was interested in this as well. My use case is making a Julia tutorial where I want to display some exercises and hide the solutions at first.
Following the Beamer example, I came up with:
---
title: TITLE
author: AUTHOR
date: DATE
---
```julia; echo=false
struct BeginDropdown
title::String
end
BeginDropdown() = BeginDropdown("")
Base.show(io::IO, m::MIME"text/html", b::BeginDropdown) = write(io, "<details><summary style=\"display:list-item\">$(b.title)</summary>")
struct EndDropdown
end
Base.show(io::IO, m::MIME"text/html", e::EndDropdown) = write(io, "</details>")
! BeginDropdown("My dropdown")
1 + 1
! EndDropdown()
Note the addition of `style=\"display:list-item\"` in the summary tag, otherwise I found that the disclosure triangle is missing (see [this StackOverflow question for reference](https://stackoverflow.com/questions/67495928/missing-disclosure-triangle-when-using-the-summary-tag)).
Is it possible to implement the code blocks folding similar to what is seen in R Markdown and described here:
https://bookdown.org/yihui/rmarkdown-cookbook/fold-show.html
Rationale:
Realistically, documents are passed around an organization to people of different specialization. It makes the most sense to have the code initially hidden so that managers, executives or others without enough coding experience to read the document without being distracted by code detail. On the other hand, users with sufficient coding knowledge would be able to peer review/inspect the code on the fly by simply unhiding/unfolding code blocks.
https://www.youtube.com/watch?v=w_97Vr-d3yM