-
-
Notifications
You must be signed in to change notification settings - Fork 413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Broken display of AbstractString
s when preferred MIME type istextmime
#1113
Comments
Why would an The reason for this behavior is that it allows you to do things like |
My particular use case is for a Thank you for the clarification! Does |
Yes, it would probably suffice to change the definition of function limitstringmime(mime::MIME, x, forcetext=false, mayberawtext=true) change this line to if israwtext(mime, x) && mayberawtext and change this line to: display_mimestring(m::MIME, x) = (m, limitstringmime(m, x, false, false)) |
Alternatively, an even simpler and probably better solution would be to change this line to israwtext(m::MIME, x::AbstractString) = !showable(m, x) so that we only treat |
Description
Users implementing
show
methods for anAbstractString
will have a broken display if the preferred MIME typeistextmime
. A motivating example is in Typstry.jl, which implementsshow
for"image/png"
and"image/svg+xml"
. Both of these methods work in Pluto.jl, but only"image/png"
works in IJulia.jl. This is because"image/svg+xml"
is preferred over"image/png"
, but this format assumes that anAbstractString
is "raw data". Instead of dispatching toshow
, it is returned as aString
.I don't really understand this assumption, why is it being used? The only thing I have found so far is the same assumption in
repr
and presume that's where it came from. A notable difference is that users are able to implementrepr
to patch in a fix.Possible Solutions
AbstractString
is "raw data"israwtext
String(repr(mime, x; context = InlineIOContext(buf)))
repr
, while preserving the preexisting behavior otherwise becauserepr
uses the same assumptionString
1. The output of
versioninfo()
IJulia v0.24.2
2. How you installed Julia
juliaup
3. A minimal working example (MWE), also known as a minimum reproducible example
The text was updated successfully, but these errors were encountered: