How is org mode an absolute html export path?

I need to export the absolute URL of the image in html in the org-mode emacs file:

when I write the following code:

[[file:/images/a.jgp]]

html code export:

<img src="file:///images/a.jpg" >

but I need:

<img src="/images/a.jgp">

so how can i export what i wanted instead of using a tag #+BEGIN_HTML?

ps: my emacs config:

 16 ;; org-mode project define
 17 (setq org-publish-project-alist
 18       '(
 19         ("org-blog-content"
 20          ;; Path to your org files.
 21          :base-directory "~/ChinaXing.org/org/"
 22          :base-extension "org"
 23 
 24          ;; Path to your jekyll project.
 25          :publishing-directory "~/ChinaXing.org/jekyll/"
 26          :recursive t
 27          :publishing-function org-publish-org-to-html
 28          :headline-levels 4
 29          :html-extension "html"
 30          :table-of-contents t
 31          :body-only t ;; Only export section between <body></body>
 32          )
 33 
 34         ("org-blog-static"
 35          :base-directory "~/ChinaXing.org/org/"
 36          :base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf\\|php\\|svg"
 37          :publishing-directory "~/ChinaXing.org/jekyll/"
 38          :recursive t
 39          :publishing-function org-publish-attachment)
 40         ("blog" :components ("org-blog-content" "org-blog-static"))
 41         ))
+5
source share
1 answer

The way to do this is to register a new kind of link in org-mode using org-add-link-type. This allows you to customize your export format.

org-add-link-typeprefix is ​​required, "what happens when you click a link?" export functions and functions.

img, [[img:logo.png][Logo]]. ../images/ ( .org), - /images/. , .emacs :

(defun org-custom-link-img-follow (path)
  (org-open-file-with-emacs
   (format "../images/%s" path)))

(defun org-custom-link-img-export (path desc format)
  (cond
   ((eq format 'html)
    (format "<img src=\"/images/%s\" alt=\"%s\"/>" path desc))))

(org-add-link-type "img" 'org-custom-link-img-follow 'org-custom-link-img-export)

, , , . , C-h f org-add-link-type .

, , , (, [[post:otherfile.org][Other File]]). Jekyll, double-% s.

(defun org-custom-link-post-follow (path)
  (org-open-file-with-emacs path))

(defun org-custom-link-post-export (path desc format)
  (cond
   ((eq format 'html)
    (format "<a href=\"{%% post_url %s %%}\">%s</a>" path desc))))

(org-add-link-type "post" 'org-custom-link-post-follow 'org-custom-link-post-export)
+9

All Articles