JuliaPluto / PlutoUI.jl

https://featured.plutojl.org/basic/plutoui.jl
The Unlicense
299 stars 54 forks source link

Lift `AbstractString` type restriction on `summary` arg of `details` #295

Closed genericallyterrible closed 3 months ago

genericallyterrible commented 4 months ago

summary was initially restricted to AbstractString to ensure good default behavior. Non-inline elements would easily create undesirable results an end-user could not remedy other than to only use string-like objects. Here is an example with a long heading:

image

Even MDN demonstrates this issue:

image

The restriction of only plain string content within <summary> elements is not one enforced by specification and so should be removed, provided an updated implementation can deliver a good default behavior for most simple cases.

Inspired: https://github.com/JuliaPluto/PlutoUI.jl/pull/290#issuecomment-1959312566

rgouveiamendes commented 4 months ago

If this helps, for Markdown I somehow got a solution with a pretty straightforward CSS trick:

pluto-output summary > .markdown {
        display:inline-flex;
        max-width:98%;
    }

(see for example here.)

genericallyterrible commented 4 months ago

Ended up adding a simple div wrapper for non-string values with this set of styles:

pluto-output div.summary-title {
    display: inline-block;
    width: calc(100% - 1em);
    margin-left: -1em;
    padding-left: 1em;
}