Hide or collapse text in Pluto

In some cases, it can be useful to hide text (as opposed to markdown) in notebooks when certain details may interrupt the flow of one’s main points. The analog in a static document would be a footnote. Is there a way to hide or collapse text in Pluto so that readers can optionally access certain information if desired?

I tried adding html with @htl, but it would not respond to a click. Here is the code.

I think one of the issues is that I need to return something in the @htl block, but its not clear to me what should be returned. I tried coll and document without success.

I came across details(md""" """). I think this should suffice for my purposes.

3 Likes

Where did you get the details function from?

The most straightforward solution I’ve found would seem to be

    let
	    content = md"""The above macro generates two functions, one is `f` and another is `~f` (or `Inv(f)`). The `x += y * constant` is translated to function `(x, y, constant) = PlusEq(*)(x, y, constant)`, where the function `PlusEq(*)` is clearly bijective.
    blablabla...
    """
	    HTML("<details><summary><strong>For experts</strong></summary>$(html(content))</details>")
    end
1 Like

Thanks for your suggestion. I used PlutoUI. Here is the syntax that currently works:

begin
	using PlutoUI
	text = md"""
	some text
	"""
	details("Summary", text)
end
1 Like

That’s what I had assumed. Apparently, for some reason I don’t understand, my notebook ended up with an ancient version of PlutoUI that didn’t have that function.

It appears details was added in v0.7.56 in Feb 2024 (not sure how you already had it in 2021 :wink:)

It doesn’t help that details isn’t mentioned in the PlutoUI documentation! In any case, it’s working now. Thanks!

That is strange. Maybe details was moved from Pluto to PlutoUI. In either case, I am glad it is working!