Rich content handling for CIDER. Mostly derived from the pprint middleware.
In the long ago, @technomancy [1] talked about his vision for using nREPL to support multimedia results beyond plain text, ala DrRacket and other "rich" REPLs. There was an initial cut at this [2], which never became part of the mainline Emacs tooling.
The goal of this module is to provide some support for recognizing multimedia objects (images and URIs thereto) as the result of evaluation, so that they can be rendered by a REPL.
The design of this module is based heavily on RFC-2045 [3] which
describes messages packaged with Content-Type
,
Content-Transfer-Encoding
and of course a body in that it seeks to
provide decorated responses which contain metadata which a client
can use to provide a rich interpretation.
There's also RFC-2017 [4] which defines the message/external-body
MIME type for defining messages which don't contain their own
bodies.
The basic architecture of this changeset is that eval results are inspected, and matched against two fundamental supported cases. One is that the value is actually a binary Java image, which can be MIME encoded and transmitted back directly. The other is that the object is some variant of a URI (such as a file naming an image or other content) which cannot be directly serialized. In this second case we send an RFC-2017 response which provides the URL from which a client could request the nREPL server slurp the desired content.
Hence the slurp middleware which slurps URLs and produces MIME coded data.
[1] https://groups.google.com/forum/#!topic/clojure-tools/rkmJ-5086RY [2] https://github.com/technomancy/nrepl-discover/blob/master/src/nrepl/discover/samples.clj#L135 [3] https://tools.ietf.org/html/rfc2045 [4] https://tools.ietf.org/html/rfc2017
Rich content handling for CIDER. Mostly derived from the pprint middleware. --- In the long ago, @technomancy [1] talked about his vision for using nREPL to support multimedia results beyond plain text, ala DrRacket and other "rich" REPLs. There was an initial cut at this [2], which never became part of the mainline Emacs tooling. The goal of this module is to provide some support for recognizing multimedia objects (images and URIs thereto) as the result of evaluation, so that they can be rendered by a REPL. The design of this module is based heavily on RFC-2045 [3] which describes messages packaged with `Content-Type`, `Content-Transfer-Encoding` and of course a body in that it seeks to provide decorated responses which contain metadata which a client can use to provide a rich interpretation. There's also RFC-2017 [4] which defines the `message/external-body` MIME type for defining messages which don't contain their own bodies. The basic architecture of this changeset is that eval results are inspected, and matched against two fundamental supported cases. One is that the value is actually a binary Java image, which can be MIME encoded and transmitted back directly. The other is that the object is some variant of a URI (such as a file naming an image or other content) which cannot be directly serialized. In this second case we send an RFC-2017 response which provides the URL from which a client could request the nREPL server slurp the desired content. Hence the slurp middleware which slurps URLs and produces MIME coded data. --- [1] https://groups.google.com/forum/#!topic/clojure-tools/rkmJ-5086RY [2] https://github.com/technomancy/nrepl-discover/blob/master/src/nrepl/discover/samples.clj#L135 [3] https://tools.ietf.org/html/rfc2045 [4] https://tools.ietf.org/html/rfc2017
Consumes an nREPL response, having a :value
. If the :value
is of a
recognized type, then rewrite the response to have a :content-type
being a
MIME type of the content, and a :body
to re-use the RFC term for the message
payload.
Dispatches on the [[clojure.core/type]] of the value, i.e. the metadata
:type
value, or the class.
Consumes an nREPL response, having a `:value`. If the `:value` is of a recognized type, then rewrite the response to have a `:content-type` being a MIME type of the content, and a `:body` to re-use the RFC term for the message payload. Dispatches on the [[clojure.core/type]] of the value, i.e. the metadata `:type` value, or the class.
(content-type-transport transport)
Transport proxy which allows this middleware to intercept responses and inspect / alter them.
Transport proxy which allows this middleware to intercept responses and inspect / alter them.
(external-body-response value)
Partial response map having an external-body content-type referring to the given URL.
See RFC-2017: Definition of the URL MIME External-Body Access-Type.
Partial response map having an external-body content-type referring to the given URL. See RFC-2017: Definition of the URL MIME External-Body Access-Type.
(handle-content-type handler msg)
Handler for inspecting the results of the eval
op, attempting to
detect content types and generate richer responses when content
information is available.
Requires that the user opt-in by providing the content-type
key in
nREPL requests, same as the pprint middleware.
Note that this middleware makes no attempt to prevent pretty-printing of the eval result, which could lead to double output in some REPL clients.
Handler for inspecting the results of the `eval` op, attempting to detect content types and generate richer responses when content information is available. Requires that the user opt-in by providing the `content-type` key in nREPL requests, same as the pprint middleware. Note that this middleware makes no attempt to prevent pretty-printing of the eval result, which could lead to double output in some REPL clients.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close