Browse Source

org-info: Correctly export info links to HTML

* lisp/org-info.el (org-info-export): New function.

Reported-by: Richard Y. Kim <emacs18@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/96779>
Nicolas Goaziou 10 years ago
parent
commit
7b97b631ef
1 changed files with 14 additions and 1 deletions
  1. 14 1
      lisp/org-info.el

+ 14 - 1
lisp/org-info.el

@@ -40,7 +40,7 @@
 (defvar Info-current-node)
 
 ;; Install the link type
-(org-add-link-type "info" 'org-info-open)
+(org-add-link-type "info" 'org-info-open 'org-info-export)
 (add-hook 'org-store-link-functions 'org-info-store-link)
 
 ;; Implementation
@@ -81,6 +81,19 @@
 				    nodename-or-index)))))
     (user-error "Could not open: %s" name)))
 
+(defun org-info-export (path desc format)
+  "Export an info link.
+See `org-add-link-type' for details about PATH, DESC and FORMAT."
+  (when (eq format 'html)
+    (or (string-match "\\(.*\\)[#:]:?\\(.*\\)" path)
+	(string-match "\\(.*\\)" path))
+    (let ((filename (match-string 1 path))
+	  (node (or (match-string 2 path) "Top")))
+      (format "<a href=\"%s.html#%s\">%s</a>"
+	      filename
+	      (replace-regexp-in-string " " "-" node)
+	      (or desc path)))))
+
 (provide 'org-info)
 
 ;;; org-info.el ends here