summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <n.goaziou@gmail.com>2014-04-17 11:34:54 +0200
committerNicolas Goaziou <n.goaziou@gmail.com>2014-04-17 11:34:54 +0200
commitfffd055ac5e920e744e350a1ad164494aec9fa91 (patch)
treeb76e7258e4ae3c5e7bb419d57cf7b201493f1fb1
parent5ec31814f934b65c8071b320a3fd567b351e0e8f (diff)
parent9dac00129d5ab939bc535e9dc42b8243f1fc710f (diff)
downloadorg-mode-fffd055ac5e920e744e350a1ad164494aec9fa91.tar.gz
Merge branch 'maint'
Conflicts: lisp/org-element.el lisp/ox-html.el
-rw-r--r--contrib/lisp/ox-deck.el2
-rw-r--r--contrib/lisp/ox-groff.el11
-rw-r--r--lisp/org-element.el12
-rw-r--r--lisp/org.el97
-rw-r--r--lisp/ox-html.el23
-rw-r--r--lisp/ox-latex.el10
-rw-r--r--lisp/ox-man.el13
-rw-r--r--lisp/ox-md.el8
-rw-r--r--lisp/ox-odt.el11
-rw-r--r--lisp/ox-texinfo.el8
-rw-r--r--testing/lisp/test-org-element.el6
11 files changed, 94 insertions, 107 deletions
diff --git a/contrib/lisp/ox-deck.el b/contrib/lisp/ox-deck.el
index ea2d8fe..0ebde41 100644
--- a/contrib/lisp/ox-deck.el
+++ b/contrib/lisp/ox-deck.el
@@ -378,7 +378,7 @@ the \"slide\" class will be added to the to the list element,
(defun org-deck-link (link desc info)
(replace-regexp-in-string "href=\"#" "href=\"#outline-container-"
- (org-html-link link desc info)))
+ (org-export-with-backend 'html link desc info)))
(defun org-deck-template (contents info)
"Return complete document string after HTML conversion.
diff --git a/contrib/lisp/ox-groff.el b/contrib/lisp/ox-groff.el
index 7b110a1..7974051 100644
--- a/contrib/lisp/ox-groff.el
+++ b/contrib/lisp/ox-groff.el
@@ -1251,13 +1251,10 @@ INFO is a plist holding contextual information. See
(imagep (org-export-inline-image-p
link org-groff-inline-image-rules))
(path (cond
- ((member type '("http" "https" "ftp"))
- (concat type "://" raw-path))
- ((string= type "mailto") (concat type ":" raw-path))
- ((string= type "file")
- (if (file-name-absolute-p raw-path)
- (concat "file://" (expand-file-name raw-path))
- (concat "file://" raw-path)))
+ ((member type '("http" "https" "ftp" "mailto"))
+ (concat type ":" raw-path))
+ ((and (string= type "file") (file-name-absolute-p raw-path))
+ (concat "file://" raw-path))
(t raw-path)))
protocol)
(cond
diff --git a/lisp/org-element.el b/lisp/org-element.el
index 13837e9..29a90be 100644
--- a/lisp/org-element.el
+++ b/lisp/org-element.el
@@ -3002,18 +3002,20 @@ Assume point is at the beginning of the link."
(save-excursion
(setq post-blank (progn (goto-char link-end) (skip-chars-forward " \t"))
end (point))
- ;; Extract search option and opening application out of
- ;; "file"-type links.
+ ;; Special "file" type link processing.
(when (member type org-element-link-type-is-file)
- ;; Application.
+ ;; Extract opening application and search option.
(cond ((string-match "^file\\+\\(.*\\)$" type)
(setq application (match-string 1 type)))
((not (string-match "^file" type))
(setq application type)))
- ;; Extract search option from PATH.
- (when (string-match "::\\(.*\\)$" path)
+ (when (string-match "::\\(.*\\)\\'" path)
(setq search-option (match-string 1 path)
path (replace-match "" nil nil path)))
+ ;; Normalize URI.
+ (when (and (not (org-string-match-p "\\`//" path))
+ (file-name-absolute-p path))
+ (setq path (concat "//" (expand-file-name path))))
;; Make sure TYPE always reports "file".
(setq type "file"))
(list 'link
diff --git a/lisp/org.el b/lisp/org.el
index 7cd96eb..e245d6d 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5669,54 +5669,55 @@ stacked delimiters is N. Escaping delimiters is not possible."
(defun org-make-link-regexps ()
"Update the link regular expressions.
This should be called after the variable `org-link-types' has changed."
- (setq org-link-types-re
- (concat "\\`" (regexp-opt org-link-types t) ":\\(?://\\)")
- org-link-re-with-space
- (concat "<?" (regexp-opt org-link-types t) ":\\(?://\\)"
- "\\([^" org-non-link-chars " ]"
- "[^" org-non-link-chars "]*"
- "[^" org-non-link-chars " ]\\)>?")
- org-link-re-with-space2
- (concat "<?" (regexp-opt org-link-types t) ":\\(?://\\)?"
- "\\([^" org-non-link-chars " ]"
- "[^\t\n\r]*"
- "[^" org-non-link-chars " ]\\)>?")
- org-link-re-with-space3
- (concat "<?" (regexp-opt org-link-types t) ":\\(?://\\)?"
- "\\([^" org-non-link-chars " ]"
- "[^\t\n\r]*\\)")
- org-angle-link-re
- (concat "<" (regexp-opt org-link-types t) ":\\(?://\\)?"
- "\\([^" org-non-link-chars " ]"
- "[^" org-non-link-chars "]*"
- "\\)>")
- org-plain-link-re
- (concat
- "\\<" (regexp-opt org-link-types t) ":\\(?://\\)?"
- (org-re "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)"))
- ;; "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)")
- org-bracket-link-regexp
- "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]"
- org-bracket-link-analytic-regexp
- (concat
- "\\[\\["
- "\\(" (regexp-opt org-link-types t) ":\\(?://\\)?\\)?"
- "\\([^]]+\\)"
- "\\]"
- "\\(\\[" "\\([^]]+\\)" "\\]\\)?"
- "\\]")
- org-bracket-link-analytic-regexp++
- (concat
- "\\[\\["
- "\\(" (regexp-opt (cons "coderef" org-link-types) t) ":\\(?://\\)?\\)?"
- "\\([^]]+\\)"
- "\\]"
- "\\(\\[" "\\([^]]+\\)" "\\]\\)?"
- "\\]")
- org-any-link-re
- (concat "\\(" org-bracket-link-regexp "\\)\\|\\("
- org-angle-link-re "\\)\\|\\("
- org-plain-link-re "\\)")))
+ (let ((types-re (regexp-opt org-link-types t)))
+ (setq org-link-types-re
+ (concat "\\`" types-re ":")
+ org-link-re-with-space
+ (concat "<?" types-re ":"
+ "\\([^" org-non-link-chars " ]"
+ "[^" org-non-link-chars "]*"
+ "[^" org-non-link-chars " ]\\)>?")
+ org-link-re-with-space2
+ (concat "<?" types-re ":"
+ "\\([^" org-non-link-chars " ]"
+ "[^\t\n\r]*"
+ "[^" org-non-link-chars " ]\\)>?")
+ org-link-re-with-space3
+ (concat "<?" types-re ":"
+ "\\([^" org-non-link-chars " ]"
+ "[^\t\n\r]*\\)")
+ org-angle-link-re
+ (concat "<" types-re ":"
+ "\\([^" org-non-link-chars " ]"
+ "[^" org-non-link-chars "]*"
+ "\\)>")
+ org-plain-link-re
+ (concat
+ "\\<" types-re ":"
+ (org-re "\\([^ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:] \t\n]\\|/\\)\\)\\)"))
+ ;; "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)")
+ org-bracket-link-regexp
+ "\\[\\[\\([^][]+\\)\\]\\(\\[\\([^][]+\\)\\]\\)?\\]"
+ org-bracket-link-analytic-regexp
+ (concat
+ "\\[\\["
+ "\\(" types-re ":\\)?"
+ "\\([^]]+\\)"
+ "\\]"
+ "\\(\\[" "\\([^]]+\\)" "\\]\\)?"
+ "\\]")
+ org-bracket-link-analytic-regexp++
+ (concat
+ "\\[\\["
+ "\\(" (regexp-opt (cons "coderef" org-link-types) t) ":\\)?"
+ "\\([^]]+\\)"
+ "\\]"
+ "\\(\\[" "\\([^]]+\\)" "\\]\\)?"
+ "\\]")
+ org-any-link-re
+ (concat "\\(" org-bracket-link-regexp "\\)\\|\\("
+ org-angle-link-re "\\)\\|\\("
+ org-plain-link-re "\\)"))))
(org-make-link-regexps)
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 8379fb2..e6c3cdd 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2721,24 +2721,21 @@ INFO is a plist holding contextual information. See
(desc (org-string-nw-p desc))
(path
(cond
- ((member type '("http" "https" "ftp"))
- (org-link-escape-browser
- (org-link-unescape (concat type "://" raw-path))))
- ((string= type "mailto")
- (org-link-escape-browser
- (org-link-unescape (concat type ":" raw-path))))
+ ((member type '("http" "https" "ftp" "mailto"))
+ (org-link-escape
+ (org-link-unescape
+ (concat type ":" raw-path)) org-link-escape-chars-browser))
((string= type "file")
;; Treat links to ".org" files as ".html", if needed.
(setq raw-path
(funcall link-org-files-as-html-maybe raw-path info))
;; If file path is absolute, prepend it with protocol
- ;; component - "file://".
- (cond ((file-name-absolute-p raw-path)
- (setq raw-path
- (concat "file://" (expand-file-name
- raw-path))))
- ((and home use-abs-url)
- (setq raw-path (concat (file-name-as-directory home) raw-path))))
+ ;; component - "file:".
+ (cond
+ ((file-name-absolute-p raw-path)
+ (setq raw-path (concat "file:" raw-path)))
+ ((and home use-abs-url)
+ (setq raw-path (concat (file-name-as-directory home) raw-path))))
;; Add search option, if any. A search option can be
;; relative to a custom-id or a headline title. Append
;; a hash sign to any unresolved option, as it might point
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 08ea285..a241a91 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -1906,12 +1906,10 @@ INFO is a plist holding contextual information. See
(imagep (org-export-inline-image-p
link org-latex-inline-image-rules))
(path (cond
- ((member type '("http" "https" "ftp"))
- (concat type "://" raw-path))
- ((string= type "mailto") (concat type ":" raw-path))
- ((string= type "file")
- (if (not (file-name-absolute-p raw-path)) raw-path
- (concat "file://" (expand-file-name raw-path))))
+ ((member type '("http" "https" "ftp" "mailto"))
+ (concat type ":" raw-path))
+ ((and (string= type "file") (file-name-absolute-p raw-path))
+ (concat "file:" raw-path))
(t raw-path)))
protocol)
(cond
diff --git a/lisp/ox-man.el b/lisp/ox-man.el
index 6fa238b..987de40 100644
--- a/lisp/ox-man.el
+++ b/lisp/ox-man.el
@@ -638,20 +638,15 @@ CONTENTS is nil. INFO is a plist holding contextual information."
DESC is the description part of the link, or the empty string.
INFO is a plist holding contextual information. See
`org-export-data'."
-
(let* ((type (org-element-property :type link))
(raw-path (org-element-property :path link))
;; Ensure DESC really exists, or set it to nil.
(desc (and (not (string= desc "")) desc))
-
(path (cond
- ((member type '("http" "https" "ftp"))
- (concat type "://" raw-path))
- ((string= type "mailto") (concat type ":" raw-path))
- ((string= type "file")
- (if (file-name-absolute-p raw-path)
- (concat "file://" (expand-file-name raw-path))
- (concat "file://" raw-path)))
+ ((member type '("http" "https" "ftp" "mailto"))
+ (concat type ":" raw-path))
+ ((and (string= type "file") (file-name-absolute-p raw-path))
+ (concat "file:" raw-path))
(t raw-path)))
protocol)
(cond
diff --git a/lisp/ox-md.el b/lisp/ox-md.el
index 03c6dc6..578f1d0 100644
--- a/lisp/ox-md.el
+++ b/lisp/ox-md.el
@@ -342,13 +342,13 @@ a communication channel."
(path
(cond
((member type '("http" "https" "ftp"))
- (concat type "://" raw-path))
- ((equal type "file")
+ (concat type ":" raw-path))
+ ((string= type "file")
(let ((path (funcall link-org-files-as-md raw-path)))
(if (not (file-name-absolute-p path)) path
;; If file path is absolute, prepend it
- ;; with "file://" component.
- (concat "file://" (expand-file-name raw-path)))))
+ ;; with "file:" component.
+ (concat "file:" path))))
(t raw-path))))
(if (not contents) (format "<%s>" path)
(format "[%s](%s)" contents path)))))))
diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el
index 07848e8..4d2f257 100644
--- a/lisp/ox-odt.el
+++ b/lisp/ox-odt.el
@@ -2711,13 +2711,10 @@ INFO is a plist holding contextual information. See
(imagep (org-export-inline-image-p
link org-odt-inline-image-rules))
(path (cond
- ((member type '("http" "https" "ftp"))
- (concat type "://" raw-path))
- ((string= type "mailto") (concat type ":" raw-path))
- ((string= type "file")
- (if (file-name-absolute-p raw-path)
- (concat "file://" (expand-file-name raw-path))
- (concat "file://" raw-path)))
+ ((member type '("http" "https" "ftp" "mailto"))
+ (concat type ":" raw-path))
+ ((and (string= type "file") (file-name-absolute-p raw-path))
+ (concat "file:" raw-path))
(t raw-path)))
;; Convert & to &amp; for correct XML representation
(path (replace-regexp-in-string "&" "&amp;" path))
diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el
index a1d06b4..9c22153 100644
--- a/lisp/ox-texinfo.el
+++ b/lisp/ox-texinfo.el
@@ -1221,11 +1221,9 @@ INFO is a plist holding contextual information. See
(desc (and (not (string= desc "")) desc))
(path (cond
((member type '("http" "https" "ftp"))
- (concat type "://" raw-path))
- ((string= type "file")
- (if (file-name-absolute-p raw-path)
- (concat "file://" (expand-file-name raw-path))
- (concat "file://" raw-path)))
+ (concat type ":" raw-path))
+ ((and (string= type "file") (file-name-absolute-p raw-path))
+ (concat "file:" raw-path))
(t raw-path)))
(email (if (string= type "mailto")
(let ((text (replace-regexp-in-string
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index 0f81a79..1bc2a53 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1361,10 +1361,12 @@ e^{i\\pi}+1=0
;; ... with expansion.
(should
(equal
- "orgmode.org/worg"
+ "//orgmode.org/worg"
(org-test-with-temp-text "[[Org:worg]]"
(let ((org-link-abbrev-alist '(("Org" . "http://orgmode.org/"))))
- (org-element-property :path (org-element-context))))))
+ (org-element-property
+ :path
+ (org-element-map (org-element-parse-buffer) 'link 'identity nil t))))))
;; ... with translation.
(should
(equal