-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Make application/julia a text MIME #18441
Conversation
(I personally hate the fact that programming languages are supposedly in the "application" namespace and not in "text". But IANA does not seem particularly consistent here.... see text/ecmascript vs application/javascript, and those are basically the same language!) |
Note that |
I suspect this definition would work as well: istextmime{T}(::MIME{T}) = startswith(string(T), "text/") || T in [... list of other mimes ...] Constant-folding during specialization should make performance equivalent to presently; if that does not happen then I suspect marking some things |
The |
FWIW, the Freedesktop.org shared MIME database has a |
@@ -81,7 +81,7 @@ istextmime(m::AbstractString) = istextmime(MIME(m)) | |||
reprmime(m::AbstractString, x) = reprmime(MIME(m), x) | |||
stringmime(m::AbstractString, x) = stringmime(MIME(m), x) | |||
|
|||
for mime in ["text/vnd.graphviz", "text/latex", "text/calendar", "text/n3", "text/richtext", "text/x-setext", "text/sgml", "text/tab-separated-values", "text/x-vcalendar", "text/x-vcard", "text/cmd", "text/css", "text/csv", "text/html", "text/javascript", "text/markdown", "text/plain", "text/vcard", "text/xml", "application/atom+xml", "application/ecmascript", "application/json", "application/rdf+xml", "application/rss+xml", "application/xml-dtd", "application/postscript", "image/svg+xml", "application/x-latex", "application/xhtml+xml", "application/javascript", "application/xml", "model/x3d+xml", "model/x3d+vrml", "model/vrml"] | |||
for mime in ["application/atom+xml", "application/ecmascript", "application/javascript", "application/julia", "application/json", "application/postscript", "application/rdf+xml", "application/rss+xml", "application/x-latex", "application/xhtml+xml", "application/xml", "application/xml-dtd", "image/svg+xml", "model/vrml", "model/x3d+vrml", "model/x3d+xml", "text/calendar", "text/cmd", "text/css", "text/csv", "text/html", "text/javascript", "text/latex", "text/markdown", "text/n3", "text/plain", "text/richtext", "text/sgml", "text/tab-separated-values", "text/vcard", "text/vnd.graphviz", "text/x-setext", "text/x-vcalendar", "text/x-vcard", "text/xml"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should line wrap this while we're at it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a standard way to wrap long for
loops? I just pushed to the beginning of line here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally follow the matlab convention of indenting line continuations of block openers one level deeper than the body of the block
There seems to be demand for a more advanced change. I'm playing around with turning So the new change implements Remaining issues: |
9b144d8
to
c30e797
Compare
Hmm, it looks like the trait did not avoid the |
The compiler really doesn't like the complexity of the Alternatively, we can put the |
macro textmime(mime) | ||
Base.depwarn(string("`@textmime mime` is deprecated; use ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if deprecated, it should probably move to deprecated.jl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It needs to be in the Multimedia
module though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, is it not exported from there? could be eval'ed into that module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
I doubt the performance is an issue, so I think this should be good to go now? |
I guess so. I have to be honest that I'm not a huge fan of the whole traits technique in cases like this; it seems like an overly complicated way to determine something at compile time that is unlikely to ever be performance-sensitive. |
In fact, the original approach was with booleans; then I switched to traits because I ran into #17880, and then I discovered that the functions was too complex for even traits to fix the type instability... |
Speaking for myself, I'd prefer booleans. |
18f0153
to
b3e1298
Compare
@stevengj Just pushed a boolean version. The boolean version is far simpler too, and probably also has lower compilation overhead. I like it also. |
Oops, I need to fix the deprecated |
I don't think we generally add tests for deprecations. |
# Deprecate @textmime into the Multimedia module, #18441 | ||
eval(Multimedia, :(macro textmime(mime) | ||
Base.depwarn(string("`@textmime mime` is deprecated; use ", | ||
"`Base.Multimedia.mimetypetype(::MIME{mime}) = ", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the deprecation now be Base.istextmime(::MIME{mime}) = true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. The code is correct, but I forgot to update the text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
6c066c3
to
ee6ee0c
Compare
Is this good to squash and merge? |
Add
application/julia
as a text MIME, and sort the list of text MIMEs.I wonder if
istextmime
could be made a little more intelligent. All mime types withtext
should be text MIMEs, right?