@@ -948,30 +948,26 @@ As an example, if DATA only contains the mimetype
948948
949949(defun jupyter-org--find-mime-types (req-types )
950950 " Return the keywords in `jupyter-org-mime-types' that match REQ-TYPES.
951+ REQ-TYPES is a string such as \" plain\" , \" plain html\" , or
952+ \" text/plain\" . The string \" text\" is translated to the keyword
953+ `:text/plain' and \" image\" to `:image/png' .
951954
952- If a match is not found, return nil. Try to be intelligent and
953- return what the user might intend to use.
954-
955- REQ-TYPES can be a string such as `plain' , `plain html', or
956- `text/plain' . The string `text' is translated to `:text/plain'
957- and `image' to `:image/png' ."
958- (when req-types
955+ If a match is not found, return nil."
956+ (when (stringp req-types)
959957 ; ; Iterate the user-specified mimetypes looking for symbols that match a
960958 ; ; symbol in `jupyter-org-mime-types' . Invalid mimetypes are ignored.
961- (delete nil
962- (mapcar
963- (lambda (req-type )
964- (pcase req-type
965- (" text" :text/plain )
966- (" image" :image/png )
967- ((pred stringp)
968- (let ((regexp (if (string-match " /" req-type)
969- req-type
970- (concat " /" req-type " $" ))))
971- (cl-loop for ii in jupyter-org-mime-types
972- if (string-match regexp (symbol-name ii))
973- return ii)))))
974- (split-string req-types)))))
959+ (cl-loop
960+ with translations = `((" text" . :text/plain )
961+ (" image" . :image/png ))
962+ for req-type in (split-string req-types)
963+ for match = (or (cdr (assoc req-type translations))
964+ (let ((regexp (if (string-match " /" req-type)
965+ req-type
966+ (concat " /" req-type " $" ))))
967+ (cl-loop for mime-type in jupyter-org-mime-types
968+ if (string-match regexp (symbol-name mime-type))
969+ return mime-type)))
970+ if match collect match )))
975971
976972(cl-defmethod jupyter-org-result ((req jupyter-org-request) plist &optional metadata)
977973 " For REQ, return a rendered form of a message PLIST.
0 commit comments