4

When org-mode html export parses an .org file and encounters a link to an image, as for example [[file:/Users/user/nice_image.png]], it properly converts the link into an html figure.

I'd like to extend that behaviour to other image formats that aren't currently supported by org's publishing facilities.

To be more specific, if my .org file contains a link to medical images in, e.g., DICOM format, I'd like org-mode to

  1. recognise that the link is pointing to a DICOM,
  2. run a shell command that creates a PNG file from the DICOM,
  3. export an html figure as if the link would've been pointing to the PNG file all along.

Does anyone know how to do that?

4

Yes you can. You need to override the :export helper function for the links you want to do the processing on. For example I do a similar thing when publishing my notes with mu4e email links:

;; Exporting
(defvar my-org-mu4e-index-links
  (rx
   (: "query:i:" (group-n 1 (one-or-more any))))
  "A regex to match mu4e links of the form:

    query:i:20170228171921.21602-1-ale+qemu@clearmind.me
")

(defun my-org-mu4e-export (path desc format)
  "Format mu4e links for export."
  (when (eq format 'html)
    (when (string-match my-org-mu4e-index-links path)
      (format "<a href=\"%s%s\">%s</a>"
              "https://www.google.com/search?q="
              (match-string 1 path)
              desc))))

(org-link-set-parameters "mu4e" :export 'my-org-mu4e-export))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.