Why don't objects of my type show in Pluto?

I’ve got a type for which I’ve implemented show. When I’ve got an instantiation of the type in a Pluto doc called val, it doesn’t display when I evaluate its name unless I explicitly call show(val) or print(val). In contrast, other types, DataFrame for example, show when I evaluate the name of the variable. However, when I do the same in a simple julia repl, the behavior is as I would expect in that simply typing val invokes the show.

It appears that my type is missing something that makes it not show properly in Pluto. Could it be that I need to implement the show(io, ::MIME"…", x) variant of show? If so, what mime type do I need to implement? Or am I off base?

Seems to work:

Guessing that it’ll only show stuff evaluated at the very end of the Pluto cell.

Yes, that works and thank you.

From what I have gathered doing a couple of experiments is that Pluto seems to invoke the “text/html” show and if that’s not defined fall back to “text/plain”. I like this behavior since one can offer a nice pretty printing.

As far as I know, Pluto is not able to infer the dependency between the show definition and the cell using the show functionality. Thus, it is currently best to define the show methods in the same cell as the type itself.

Related discussion on Zulip:

So, the reason for my conclusion is that I implemented show(io::IO, ::MIME"text/plain", val) and pluto showed gave the result I get when I am using a term repl. I then added a show(io::IO, ::MIME"text/html", val) and tried it again with the result that the display was using the html version.

Whatever the reason, I’m very happy with the result, but I’d be interested in understanding the underlying mechanism.