Browse Source

org-docview.el (org-docview-export): New function to export docview links

* org-docview.el (org-docview-export): New function to export
docview links.

TINYCHANGE

Patch slightly modified by Bastien.
Дядов Васил Стоянов 5 years ago
parent
commit
6f3cb7a8b5
1 changed files with 14 additions and 1 deletions
  1. 14 1
      lisp/org-docview.el

+ 14 - 1
lisp/org-docview.el

@@ -51,9 +51,22 @@
 
 (autoload 'doc-view-goto-page "doc-view")
 
-(org-add-link-type "docview" 'org-docview-open)
+(org-add-link-type "docview" 'org-docview-open 'org-docview-export)
 (add-hook 'org-store-link-functions 'org-docview-store-link)
 
+(defun org-docview-export (link description format)
+  "Export a docview link from Org files."
+  (let* ((path (when (string-match "\\(.+\\)::.+" link)
+		 (match-string 1 link)))
+         (desc (or description link)))
+    (when (stringp path)
+      (setq path (org-link-escape (expand-file-name path)))
+      (cond
+       ((eq format 'html) (format "<a href=\"%s\">%s</a>" path desc))
+       ((eq format 'latex) (format "\href{%s}{%s}" path desc))
+       ((eq format 'ascii) (format "%s (%s)" desc path))
+       (t path)))))
+
 (defun org-docview-open (link)
   (when (string-match "\\(.*\\)::\\([0-9]+\\)$"  link)
     (let* ((path (match-string 1 link))