diff options
author | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-12-12 21:01:02 +0100 |
---|---|---|
committer | Nicolas Goaziou <mail@nicolasgoaziou.fr> | 2016-12-12 21:01:02 +0100 |
commit | 5c28ea6aad2245944bb4f626fe7b039bfbb2b91b (patch) | |
tree | 99bac36ab04b44c35ca20b4d5105b828aae94e92 | |
parent | d777418ac68611038cbf219a3a94594400c46d7c (diff) | |
download | org-mode-5c28ea6aad2245944bb4f626fe7b039bfbb2b91b.tar.gz |
ox-beamer: Fix Beamer internal links
* lisp/ox-beamer.el (org-beamer-link): Generate a label compatible
with "latex" back-end. Reduce code duplication with "ox-latex.el".
Reported-by: Eric S Fraga <e.fraga@ucl.ac.uk>
<http://permalink.gmane.org/gmane.emacs.orgmode/110771>
-rw-r--r-- | lisp/ox-beamer.el | 49 |
1 files changed, 9 insertions, 40 deletions
diff --git a/lisp/ox-beamer.el b/lisp/ox-beamer.el index c254c0b..9a26dc0 100644 --- a/lisp/ox-beamer.el +++ b/lisp/ox-beamer.el @@ -720,46 +720,15 @@ channel." "Transcode a LINK object into Beamer code. CONTENTS is the description part of the link. INFO is a plist used as a communication channel." - (let ((type (org-element-property :type link))) - (cond - ;; Link type is handled by a special function. - ((org-export-custom-protocol-maybe link contents 'beamer)) - ;; Use \hyperlink command for all internal links. - ((equal type "radio") - (let ((destination (org-export-resolve-radio-link link info))) - (if (not destination) contents - (format "\\hyperlink%s{%s}{%s}" - (or (org-beamer--element-has-overlay-p link) "") - (org-export-get-reference destination info) - contents)))) - ((and (member type '("custom-id" "fuzzy" "id")) - (let ((destination (if (string= type "fuzzy") - (org-export-resolve-fuzzy-link link info) - (org-export-resolve-id-link link info)))) - (cl-case (org-element-type destination) - (headline - (let ((label - (format "sec-%s" - (mapconcat - 'number-to-string - (org-export-get-headline-number - destination info) - "-")))) - (if (and (plist-get info :section-numbers) (not contents)) - (format "\\ref{%s}" label) - (format "\\hyperlink%s{%s}{%s}" - (or (org-beamer--element-has-overlay-p link) "") - label - contents)))) - (target - (let ((ref (org-export-get-reference destination info))) - (if (not contents) (format "\\ref{%s}" ref) - (format "\\hyperlink%s{%s}{%s}" - (or (org-beamer--element-has-overlay-p link) "") - ref - contents)))))))) - ;; Otherwise, use `latex' back-end. - (t (org-export-with-backend 'latex link contents info))))) + (or (org-export-custom-protocol-maybe link contents 'beamer) + ;; Fall-back to LaTeX export. However, if link is becomes + ;; a "\hyperlink" macro, try to sneak in Beamer overlay + ;; specification, if any. + (let ((latex-link (org-export-with-backend 'latex link contents info)) + (overlay (org-beamer--element-has-overlay-p link))) + (if (and overlay (string-match "\\`\\\\hyperlink" latex-link)) + (replace-match (concat "\\&" overlay) nil nil latex-link) + latex-link)))) ;;;; Plain List |