diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-01-21 14:19:29 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2017-01-21 14:19:29 +0100 |
commit | 7289293e4e94bcef7b872bd089db4040470e9ae9 (patch) | |
tree | 30f278ddaac4f1beb23aaf12cc65da4d2bca607b | |
parent | dbd7d995e8153e8a474e4d76dfe7a2b3e6909f6d (diff) | |
download | org-mode-7289293e4e94bcef7b872bd089db4040470e9ae9.tar.gz |
ox-texinfo: Delegate "info" links handling to "org-info.el"
* lisp/org-info.el (org-info-export): Handle links when exporting to
"texinfo" back-end.
* lisp/ox-texinfo.el (org-texinfo-link): Delegate "info" links
handling to the function above.
-rw-r--r-- | lisp/org-info.el | 22 | ||||
-rw-r--r-- | lisp/ox-texinfo.el | 6 | ||||
-rw-r--r-- | testing/lisp/test-org-info.el | 11 |
3 files changed, 22 insertions, 17 deletions
diff --git a/lisp/org-info.el b/lisp/org-info.el index 79b9bcc..a13903a 100644 --- a/lisp/org-info.el +++ b/lisp/org-info.el @@ -129,15 +129,19 @@ See `org-info-emacs-documents' and `org-info-other-documents' for details." (defun org-info-export (path desc format) "Export an info link. See `org-link-parameters' 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#%s\">%s</a>" - (org-info-map-html-url filename) - (org-info--expand-node-name node) - (or desc path))))) + (let* ((parts (split-string path "[#:]:?")) + (manual (car parts)) + (node (or (nth 1 parts) "Top"))) + (pcase format + (`html + (format "<a href=\"%s#%s\">%s</a>" + (org-info-map-html-url manual) + (org-info--expand-node-name node) + (or desc path))) + (`texinfo + (let ((title (or desc ""))) + (format "@ref{%s,%s,,%s,}" node title manual))) + (_ nil)))) (provide 'org-info) diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index e6f8d73..45c019e 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -1004,12 +1004,6 @@ INFO is a plist holding contextual information. See ;; Eventually, just return "Top" to refer to the ;; beginning of the info file. (t "Top"))))))) - ((equal type "info") - (let* ((info-path (split-string path "[:#]")) - (info-manual (car info-path)) - (info-node (or (cadr info-path) "Top")) - (title (or desc ""))) - (format "@ref{%s,%s,,%s,}" info-node title info-manual))) ((string= type "mailto") (format "@email{%s}" (concat (org-texinfo--sanitize-content path) diff --git a/testing/lisp/test-org-info.el b/testing/lisp/test-org-info.el index df0ef31..47dbaa1 100644 --- a/testing/lisp/test-org-info.el +++ b/testing/lisp/test-org-info.el @@ -21,7 +21,7 @@ (ert-deftest test-org-info/export () "Test `org-info-export' specifications." - ;; Regular export to HTML, with node. Without node, refer to "Top". + ;; Export to HTML. Without node, refer to "Top". (should (equal (org-info-export "filename#node" nil 'html) "<a href=\"filename.html#node\">filename#node</a>")) @@ -49,7 +49,14 @@ (equal "A-node-_002d_002d_002d-with-_005f_0027_0025" (let ((name (org-info-export "#A node --- with _'%" nil 'html))) (and (string-match "#\\(.*\\)\"" name) - (match-string 1 name)))))) + (match-string 1 name))))) + ;; Export to Texinfo. Without a node name, refer to "Top". + (should + (equal (org-info-export "filename" nil 'texinfo) + "@ref{Top,,,filename,}")) + (should + (equal (org-info-export "filename#node" nil 'texinfo) + "@ref{node,,,filename,}"))) |