[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Re: Bug: Plain https links with brackets are not recognised
From: |
Ihor Radchenko |
Subject: |
Re: [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)] |
Date: |
Sat, 13 Mar 2021 13:24:20 +0800 |
Sorry, attached wrong version of the patch.
Here is the right one
>From 0acb961d916d4bfde505c9f5eb16d1e8851b6c8f Mon Sep 17 00:00:00 2001
From: Ihor Radchenko <yantar92@gmail.com>
Date: Sat, 13 Mar 2021 13:16:06 +0800
Subject: [PATCH] Improve org-link-plain-re
* lisp/ol.el (org-link-make-regexps): Allow URLs with up to two levels
of nested brackets. Now, URLs like [1] can be matched. The new
regexp is taken from [2].
[1] https://doi.org/10.1016/0160-791x(79)90023-x
[2] https://daringfireball.net/2010/07/improved_regex_for_matching_urls
---
lisp/ol.el | 55 +++++++++++++++++++++++++++++++++++-------------------
1 file changed, 36 insertions(+), 19 deletions(-)
diff --git a/lisp/ol.el b/lisp/ol.el
index 8b9755b51..7ce7a4798 100644
--- a/lisp/ol.el
+++ b/lisp/ol.el
@@ -829,26 +829,43 @@ This should be called after the variable
`org-link-parameters' has changed."
(format "<%s:\\([^>\n]*\\(?:\n[ \t]*[^> \t\n][^>\n]*\\)*\\)>"
types-re)
org-link-plain-re
- (concat
- "\\<" types-re ":"
- "\\([^][ \t\n()<>]+\\(?:([[:word:]0-9_]+)\\|\\([^[:punct:]
\t\n]\\|/\\)\\)\\)")
- ;; "\\([^]\t\n\r<>() ]+[^]\t\n\r<>,.;() ]\\)")
- org-link-bracket-re
- (rx (seq "[["
- ;; URI part: match group 1.
- (group
- (one-or-more
+ (let ((non-space-bracket "[^][ \t\n()<>]+"))
+ ;; Heiristics for an URL link. Source:
+ ;;
https://daringfireball.net/2010/07/improved_regex_for_matching_urls
+ (rx-to-string
+ `(seq (regexp "\\<")
+ (regexp ,types-re)
+ ":"
+ (1+ (or (regex ,non-space-bracket)
+ (seq "("
+ (* (or (regex ,non-space-bracket)
+ (seq "("
+ (regex ,non-space-bracket)
+ ")")))
+ ")")))
+ (or (seq "("
+ (* (or (regex ,non-space-bracket)
+ (seq "("
+ (regex ,non-space-bracket)
+ ")")))
+ ")")
+ (regexp "\\([^[:punct:] \t\n]\\|/\\)")))))
+ org-link-bracket-re
+ (rx (seq "[["
+ ;; URI part: match group 1.
+ (group
+ (one-or-more
(or (not (any "[]\\"))
- (and "\\" (zero-or-more "\\\\") (any "[]"))
- (and (one-or-more "\\") (not (any "[]"))))))
- "]"
- ;; Description (optional): match group 2.
- (opt "[" (group (+? anything)) "]")
- "]"))
- org-link-any-re
- (concat "\\(" org-link-bracket-re "\\)\\|\\("
- org-link-angle-re "\\)\\|\\("
- org-link-plain-re "\\)"))))
+ (and "\\" (zero-or-more "\\\\") (any "[]"))
+ (and (one-or-more "\\") (not (any "[]"))))))
+ "]"
+ ;; Description (optional): match group 2.
+ (opt "[" (group (+? anything)) "]")
+ "]"))
+ org-link-any-re
+ (concat "\\(" org-link-bracket-re "\\)\\|\\("
+ org-link-angle-re "\\)\\|\\("
+ org-link-plain-re "\\)"))))
(defun org-link-complete-file (&optional arg)
"Create a file link using completion."
--
2.26.2
- Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Ihor Radchenko, 2021/03/12
- Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Kyle Meyer, 2021/03/12
- [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Ihor Radchenko, 2021/03/13
- Re: [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)],
Ihor Radchenko <=
- Re: [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Maxim Nikulin, 2021/03/15
- Re: [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Ihor Radchenko, 2021/03/16
- Re: [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Maxim Nikulin, 2021/03/17
- Re: [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Ihor Radchenko, 2021/03/19
- Re: [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Maxim Nikulin, 2021/03/24
- Re: [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Ihor Radchenko, 2021/03/24
- Re: [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Maxim Nikulin, 2021/03/19
- Re: [PATCH] Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Ihor Radchenko, 2021/03/19
Re: Bug: Plain https links with brackets are not recognised [9.4.4 (release_9.4.4-625-g763c7a @ /home/yantar92/.emacs.d/straight/build/org/)], Nicolas Goaziou, 2021/03/24