mirror of
https://github.com/vale981/emacs-jupyter
synced 2025-03-05 15:41:37 -05:00
jupyter-org-result: Refactor
This commit is contained in:
parent
24fa0064ee
commit
da78c8ccef
1 changed files with 23 additions and 23 deletions
|
@ -936,14 +936,13 @@ will be inserted by calling `org-element-interpret-data' first.
|
||||||
The returned result should be a representation of a MIME type's
|
The returned result should be a representation of a MIME type's
|
||||||
CONTENT. CONTENT is a property list like
|
CONTENT. CONTENT is a property list like
|
||||||
|
|
||||||
'(:data ... :metadata ...)
|
'(:data DATA :metadata METADATA)
|
||||||
|
|
||||||
that contains the data/metadata of the mime type.
|
that contains the DATA/METADATA of the mime type. As an example,
|
||||||
|
if MIME is `:text/markdown', then DATA should be the markdown
|
||||||
|
string. The returned result in this case will be
|
||||||
|
|
||||||
As an example, if DATA only contains the mimetype
|
(jupyter-org-export-block \"markdown\" DATA)"
|
||||||
`:text/markdown', then the returned results is
|
|
||||||
|
|
||||||
(jupyter-org-export-block \"markdown\" data)"
|
|
||||||
(ignore))
|
(ignore))
|
||||||
|
|
||||||
(defun jupyter-org--find-mime-types (req-types)
|
(defun jupyter-org--find-mime-types (req-types)
|
||||||
|
@ -993,27 +992,28 @@ If the source block parameters have a value for the :display
|
||||||
header argument, like \"image/png html plain\", then loop over
|
header argument, like \"image/png html plain\", then loop over
|
||||||
those mime types instead."
|
those mime types instead."
|
||||||
(cl-assert plist json-plist)
|
(cl-assert plist json-plist)
|
||||||
(org-with-point-at (jupyter-org-request-marker req)
|
(let* ((params (jupyter-org-request-block-params req))
|
||||||
(let* ((params (jupyter-org-request-block-params req))
|
(display (alist-get :display params))
|
||||||
(display-mime-types (jupyter-org--find-mime-types
|
(mime-types (or (jupyter-org--find-mime-types display)
|
||||||
(alist-get :display params))))
|
jupyter-org-mime-types)))
|
||||||
;; Push :file back into PARAMS if it was present in
|
;; Push :file back into PARAMS if it was present in
|
||||||
;; `org-babel-execute:jupyter'. That function removes it because
|
;; `org-babel-execute:jupyter'. That function removes it because
|
||||||
;; we don't want `org-babel-insert-result' to handle it.
|
;; we don't want `org-babel-insert-result' to handle it.
|
||||||
(when (jupyter-org-request-file req)
|
(when (jupyter-org-request-file req)
|
||||||
(push (cons :file (jupyter-org-request-file req)) params))
|
(push (cons :file (jupyter-org-request-file req)) params))
|
||||||
(cond
|
(or (org-with-point-at
|
||||||
((jupyter-map-mime-bundle (or display-mime-types jupyter-org-mime-types)
|
(jupyter-org-request-marker req)
|
||||||
(jupyter-normalize-data plist metadata)
|
(jupyter-map-mime-bundle mime-types
|
||||||
(lambda (mime content)
|
(jupyter-normalize-data plist metadata)
|
||||||
(jupyter-org-result mime content params))))
|
(lambda (mime content)
|
||||||
(t
|
(jupyter-org-result mime content params))))
|
||||||
(let ((warning
|
(let ((warning
|
||||||
(format
|
(format
|
||||||
"%s did not return requested mimetype(s): %s"
|
"%s did not return requested mimetype(s): %s"
|
||||||
(jupyter-message-type (jupyter-request-last-message req))
|
(jupyter-message-type (jupyter-request-last-message req))
|
||||||
(or display-mime-types jupyter-org-mime-types))))
|
mime-types)))
|
||||||
(display-warning 'jupyter warning)))))))
|
(display-warning 'jupyter warning)
|
||||||
|
nil))))
|
||||||
|
|
||||||
(cl-defmethod jupyter-org-result ((_mime (eql :application/vnd.jupyter.widget-view+json)) _content _params)
|
(cl-defmethod jupyter-org-result ((_mime (eql :application/vnd.jupyter.widget-view+json)) _content _params)
|
||||||
;; TODO: Clickable text to open up a browser
|
;; TODO: Clickable text to open up a browser
|
||||||
|
|
Loading…
Add table
Reference in a new issue