emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <n.goaziou@gmail.com>
To: Bastien <bzg@gnu.org>
Cc: sva-news@mygooglest.com, 16751@debbugs.gnu.org,
	Eli Zaretskii <eliz@gnu.org>
Subject: bug#16751: 24.3.50; Export during Org export to HTML
Date: Fri, 28 Mar 2014 19:36:12 +0100	[thread overview]
Message-ID: <8761myqig3.fsf__27444.2686736167$1396031811$gmane$org@gmail.com> (raw)
In-Reply-To: <87pplgdkz3.fsf__35463.6971526363$1395389941$gmane$org@bzg.ath.cx> (Bastien's message of "Fri, 21 Mar 2014 09:17:20 +0100")

[-- Attachment #1: Type: text/plain, Size: 232 bytes --]

Hello,

Bastien <bzg@gnu.org> writes:

> If someone wants to work on this, help is welcome.

> Let's keep the bug open in the meantime.

Unless I'm mistaken, the following patch should fix the issue.


Regards,

-- 
Nicolas Goaziou

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-Org-links-compatible-with-URI-syntax.patch --]
[-- Type: text/x-diff, Size: 4138 bytes --]

From 4d62387fe035d9aa3d1dc96d12d40c53dca2afe5 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
Date: Fri, 28 Mar 2014 19:24:38 +0100
Subject: [PATCH] Make Org links compatible with URI syntax

* lisp/org.el (org-make-link-regexps): Allow optional double slashes
  after type.  Small refactoring.

* testing/lisp/test-org-element.el (test-org-element/link-parser):
  Update test.

This patch allows to write both [[file:/file.org]] and [[file:///file.org]].
See bug#16751.
---
 lisp/org.el                      | 43 ++++++++++++++++++----------------------
 testing/lisp/test-org-element.el |  6 ++----
 2 files changed, 21 insertions(+), 28 deletions(-)

diff --git a/lisp/org.el b/lisp/org.el
index bb83eb7..53f142e 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -5658,34 +5658,29 @@ stacked delimiters is N.  Escaping delimiters is not possible."
   "Update the link regular expressions.
 This should be called after the variable `org-link-types' has changed."
   (setq org-link-types-re
-	(concat
-	 "\\`\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):")
+	(concat "\\`" (regexp-opt org-link-types t) ":\\(?://\\)")
 	org-link-re-with-space
-	(concat
-	 "<?\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):"
-	 "\\([^" org-non-link-chars " ]"
-	 "[^" org-non-link-chars "]*"
-	 "[^" org-non-link-chars " ]\\)>?")
+	(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
-	 "<?\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):"
-	 "\\([^" org-non-link-chars " ]"
-	 "[^\t\n\r]*"
-	 "[^" org-non-link-chars " ]\\)>?")
+	(concat "<?" (regexp-opt org-link-types t) ":\\(?://\\)?"
+		"\\([^" org-non-link-chars " ]"
+		"[^\t\n\r]*"
+		"[^" org-non-link-chars " ]\\)>?")
 	org-link-re-with-space3
-	(concat
-	 "<?\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):"
-	 "\\([^" org-non-link-chars " ]"
-	 "[^\t\n\r]*\\)")
+	(concat "<?" (regexp-opt org-link-types t) ":\\(?://\\)?"
+		"\\([^" org-non-link-chars " ]"
+		"[^\t\n\r]*\\)")
 	org-angle-link-re
-	(concat
-	 "<\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):"
-	 "\\([^" org-non-link-chars " ]"
-	 "[^" org-non-link-chars "]*"
-	 "\\)>")
+	(concat "<" (regexp-opt org-link-types t) ":\\(?://\\)?"
+		"\\([^" org-non-link-chars " ]"
+		"[^" org-non-link-chars "]*"
+		"\\)>")
 	org-plain-link-re
 	(concat
-	 "\\<\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):"
+	 "\\<" (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
@@ -5693,7 +5688,7 @@ This should be called after the variable `org-link-types' has changed."
 	org-bracket-link-analytic-regexp
 	(concat
 	 "\\[\\["
-	 "\\(\\(" (mapconcat 'regexp-quote org-link-types "\\|") "\\):\\)?"
+	 "\\(" (regexp-opt org-link-types t) ":\\(?://\\)?\\)?"
 	 "\\([^]]+\\)"
 	 "\\]"
 	 "\\(\\[" "\\([^]]+\\)" "\\]\\)?"
@@ -5701,7 +5696,7 @@ This should be called after the variable `org-link-types' has changed."
 	org-bracket-link-analytic-regexp++
 	(concat
 	 "\\[\\["
-	 "\\(\\(" (mapconcat 'regexp-quote (cons "coderef" org-link-types) "\\|") "\\):\\)?"
+	 "\\(" (regexp-opt (cons "coderef" org-link-types) t) ":\\(?://\\)?\\)?"
 	 "\\([^]]+\\)"
 	 "\\]"
 	 "\\(\\[" "\\([^]]+\\)" "\\]\\)?"
diff --git a/testing/lisp/test-org-element.el b/testing/lisp/test-org-element.el
index def1659..72eea22 100644
--- a/testing/lisp/test-org-element.el
+++ b/testing/lisp/test-org-element.el
@@ -1362,12 +1362,10 @@ 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-map (org-element-parse-buffer) 'link 'identity nil t))))))
+	(org-element-property :path (org-element-context))))))
   ;; ... with translation.
   (should
    (equal
-- 
1.9.1


  reply	other threads:[~2014-03-28 18:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <86fvnmoxyp.fsf@somewhere.org>
     [not found] ` <mailman.15076.1392372434.10748.bug-gnu-emacs@gnu.org>
     [not found]   ` <86txbwlkeh.fsf@somewhere.org>
     [not found]     ` <83ha7w75sc.fsf@gnu.org>
     [not found]       ` <86wqgk7npj.fsf@somewhere.org>
     [not found]         ` <mailman.15924.1393259115.10748.bug-gnu-emacs@gnu.org>
     [not found]           ` <86mwhf4jpo.fsf@somewhere.org>
     [not found]             ` <834n3n17vg.fsf@gnu.org>
2014-02-25 17:12               ` bug#16751: 24.3.50; Export during Org export to HTML Bastien
2014-02-25 17:49                 ` Eli Zaretskii
2014-02-25 18:04                 ` Nicolas Goaziou
2014-02-25 18:32                   ` Eli Zaretskii
2014-02-25 19:11                     ` Achim Gratz
     [not found]                   ` <83lhwzyrdw.fsf@gnu.org>
2014-02-25 18:41                     ` Glenn Morris
     [not found]                     ` <9e1tyrjar9.fsf@fencepost.gnu.org>
2014-02-25 20:53                       ` Eli Zaretskii
     [not found]                 ` <83ob1vytf5.fsf@gnu.org>
2014-03-01 11:53                   ` Eli Zaretskii
2014-03-21  8:17                     ` Bastien
2014-03-28 18:36                       ` Nicolas Goaziou [this message]
2014-04-10 21:03                         ` Nicolas Goaziou
2014-04-11  8:48                           ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='8761myqig3.fsf__27444.2686736167$1396031811$gmane$org@gmail.com' \
    --to=n.goaziou@gmail.com \
    --cc=16751@debbugs.gnu.org \
    --cc=bzg@gnu.org \
    --cc=eliz@gnu.org \
    --cc=sva-news@mygooglest.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).