Merge branch 'maint'

This commit is contained in:
Nicolas Goaziou 2019-12-22 14:58:14 +01:00
commit 2eeafcaf34
8 changed files with 176 additions and 233 deletions

View File

@ -2940,23 +2940,21 @@ or alternatively
#+cindex: escape syntax, for links #+cindex: escape syntax, for links
#+cindex: backslashes, in links #+cindex: backslashes, in links
Some =\= and =]= characters in the {{{var(LINK)}}} part need to be Some =\=, =[= and =]= characters in the {{{var(LINK)}}} part need to
"escaped", i.e., preceded by another =\= character. More be "escaped", i.e., preceded by another =\= character. More
specifically, the following character categories, and only them, must specifically, the following characters, and only them, must be
be escaped, in order: escaped:
1. all consecutive =\= characters at the end of the link, 1. all =[= and =]= characters,
2. any =]= character at the very end of the link, 2. every =\= character preceding either =]= or =[=,
3. all consecutive =\= characters preceding =][= or =]]= patterns, 3. every =\= character at the end of the link.
4. any =]= character followed by either =[= or =]=.
#+findex: org-link-escape #+findex: org-link-escape
Org takes for granted that such links are correctly escaped. Functions inserting links (see [[*Handling Links]]) properly escape
Functions inserting links (see [[*Handling Links]]) take care of this. ambiguous characters. You only need to bother about the rules above
You only need to bother about those rules when inserting directly, or when inserting directly, or yanking, a URI within square brackets.
yanking, a URI within square brackets. When in doubt, you may use the When in doubt, you may use the function ~org-link-escape~, which turns
function ~org-link-escape~, which turns a link string into its a link string into its escaped form.
properly escaped form.
Once a link in the buffer is complete, with all brackets present, Org Once a link in the buffer is complete, with all brackets present, Org
changes the display so that =DESCRIPTION= is displayed instead of changes the display so that =DESCRIPTION= is displayed instead of

View File

@ -50,15 +50,11 @@ Org used to percent-encode sensitive characters in the URI part of the
bracket links. bracket links.
Now, escaping mechanism uses the usual backslash character, according Now, escaping mechanism uses the usual backslash character, according
to the following rules, applied in order: to the following rules:
1. All consecutive =\= characters at the end of the link must be 1. All =[= and =]= characters in the URI must be escaped;
escaped; 2. Every =\= character preceding either =[= or =]= must be escaped;
2. Any =]= character at the very end of the link must be escaped; 3. Every =\= character at the end of the URI must be escaped.
3. All consecutive =\= characters preceding =][= or =]]= patterns must
be escaped;
4. Any =]= character followed by either =[= or =]= must be escaped;
5. Others =]= and =\= characters need not be escaped.
When in doubt, use the function ~org-link-escape~ in order to turn When in doubt, use the function ~org-link-escape~ in order to turn
a link string into its properly escaped form. a link string into its properly escaped form.

View File

@ -716,12 +716,10 @@ This should be called after the variable `org-link-parameters' has changed."
(rx (seq "[[" (rx (seq "[["
;; URI part: match group 1. ;; URI part: match group 1.
(group (group
;; Allow an even number of backslashes right (one-or-more
;; before the closing bracket. (or (not (any "[]\\"))
(or (one-or-more "\\\\") (and "\\" (zero-or-more "\\\\") (any "[]"))
(and (*? anything) (and (one-or-more "\\") (not (any "[]"))))))
(not (any "\\"))
(zero-or-more "\\\\"))))
"]" "]"
;; Description (optional): match group 2. ;; Description (optional): match group 2.
(opt "[" (group (+? anything)) "]") (opt "[" (group (+? anything)) "]")
@ -838,30 +836,21 @@ E.g. \"%C3%B6\" becomes the german o-Umlaut."
(defun org-link-escape (link) (defun org-link-escape (link)
"Backslash-escape sensitive characters in string LINK." "Backslash-escape sensitive characters in string LINK."
;; Escape closing square brackets followed by another square bracket (replace-regexp-in-string
;; or at the end of the link. Also escape final backslashes so that (rx (seq (group (zero-or-more "\\")) (group (or string-end (any "[]")))))
;; we do not escape inadvertently URI's closing bracket. (lambda (m)
(with-temp-buffer (concat (match-string 1 m)
(insert link) (match-string 1 m)
(insert (make-string (- (skip-chars-backward "\\\\")) (and (/= (match-beginning 2) (match-end 2)) "\\")))
?\\)) link nil t 1))
(while (search-backward "\]" nil t)
(when (looking-at-p "\\]\\(?:[][]\\|\\'\\)")
(insert (make-string (1+ (- (skip-chars-backward "\\\\")))
?\\))))
(buffer-string)))
(defun org-link-unescape (link) (defun org-link-unescape (link)
"Remove escaping backslash characters from string LINK." "Remove escaping backslash characters from string LINK."
(with-temp-buffer (replace-regexp-in-string
(save-excursion (insert link)) (rx (group (one-or-more "\\")) (or string-end (any "[]")))
(while (re-search-forward "\\(\\\\+\\)\\]\\(?:[][]\\|\\'\\)" nil t) (lambda (_)
(replace-match (make-string (/ (- (match-end 1) (match-beginning 1)) 2) (concat (make-string (/ (- (match-end 1) (match-beginning 1)) 2) ?\\)))
?\\) link nil t 1))
nil t nil 1))
(goto-char (point-max))
(delete-char (/ (- (skip-chars-backward "\\\\")) 2))
(buffer-string)))
(defun org-link-make-string (link &optional description) (defun org-link-make-string (link &optional description)
"Make a bracket link, consisting of LINK and DESCRIPTION. "Make a bracket link, consisting of LINK and DESCRIPTION.

View File

@ -24,7 +24,9 @@
(signal 'missing-test-dependency "Support for Python code blocks")) (signal 'missing-test-dependency "Support for Python code blocks"))
(ert-deftest test-ob-python/colnames-yes-header-argument () (ert-deftest test-ob-python/colnames-yes-header-argument ()
(org-test-with-temp-text "#+name: eg (should
(equal '(("col") hline ("a") ("b"))
(org-test-with-temp-text "#+name: eg
| col | | col |
|-----| |-----|
| a | | a |
@ -32,30 +34,30 @@
#+header: :colnames yes #+header: :colnames yes
#+header: :var x = eg #+header: :var x = eg
#+begin_src python <point>#+begin_src python
return x return x
#+end_src" #+end_src"
(org-babel-next-src-block) (org-babel-execute-src-block)))))
(should (equal '(("col") hline ("a") ("b"))
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/colnames-yes-header-argument-again () (ert-deftest test-ob-python/colnames-yes-header-argument-again ()
(org-test-with-temp-text "#+name: less-cols (should
(equal '(("a") hline ("b*") ("c*"))
(org-test-with-temp-text "#+name: less-cols
| a | | a |
|---| |---|
| b | | b |
| c | | c |
#+header: :colnames yes #+header: :colnames yes
#+begin_src python :var tab=less-cols <point>#+begin_src python :var tab=less-cols
return [[val + '*' for val in row] for row in tab] return [[val + '*' for val in row] for row in tab]
#+end_src" #+end_src"
(org-babel-next-src-block) (org-babel-execute-src-block)))))
(should (equal '(("a") hline ("b*") ("c*"))
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/colnames-nil-header-argument () (ert-deftest test-ob-python/colnames-nil-header-argument ()
(org-test-with-temp-text "#+name: eg (should
(equal '(("col") hline ("a") ("b"))
(org-test-with-temp-text "#+name: eg
| col | | col |
|-----| |-----|
| a | | a |
@ -63,30 +65,30 @@ return x
#+header: :colnames nil #+header: :colnames nil
#+header: :var x = eg #+header: :var x = eg
#+begin_src python <point>#+begin_src python
return x return x
#+end_src" #+end_src"
(org-babel-next-src-block) (org-babel-execute-src-block)))))
(should (equal '(("col") hline ("a") ("b"))
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/colnames-no-header-argument-again () (ert-deftest test-ob-python/colnames-no-header-argument-again ()
(org-test-with-temp-text "#+name: less-cols (should
(equal '(("a*") ("b*") ("c*"))
(org-test-with-temp-text "#+name: less-cols
| a | | a |
|---| |---|
| b | | b |
| c | | c |
#+header: :colnames no #+header: :colnames no
#+begin_src python :var tab=less-cols <point>#+begin_src python :var tab=less-cols
return [[val + '*' for val in row] for row in tab] return [[val + '*' for val in row] for row in tab]
#+end_src" #+end_src"
(org-babel-next-src-block) (org-babel-execute-src-block)))))
(should (equal '(("a*") ("b*") ("c*"))
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/colnames-no-header-argument () (ert-deftest test-ob-python/colnames-no-header-argument ()
(org-test-with-temp-text "#+name: eg (should
(equal '(("col") ("a") ("b"))
(org-test-with-temp-text "#+name: eg
| col | | col |
|-----| |-----|
| a | | a |
@ -94,19 +96,18 @@ return x
#+header: :colnames no #+header: :colnames no
#+header: :var x = eg #+header: :var x = eg
#+begin_src python <point>#+begin_src python
return x return x
#+end_src" #+end_src"
(org-babel-next-src-block) (org-babel-execute-src-block)))))
(should (equal '(("col") ("a") ("b"))
(org-babel-execute-src-block)))))
(ert-deftest test-ob-python/session-multiline () (ert-deftest test-ob-python/session-multiline ()
;; FIXME workaround to prevent starting prompt leaking into output ;; FIXME workaround to prevent starting prompt leaking into output
(run-python) (run-python)
(sleep-for 0 10) (sleep-for 0 10)
(org-test-with-temp-text " (should
#+begin_src python :session :results output (equal "20"
(org-test-with-temp-text "#+begin_src python :session :results output
foo = 0 foo = 0
for _ in range(10): for _ in range(10):
foo += 1 foo += 1
@ -115,26 +116,28 @@ return x
print(foo) print(foo)
#+end_src" #+end_src"
(org-babel-next-src-block) (org-babel-execute-src-block)))))
(should (equal "20" (org-babel-execute-src-block)))))
(ert-deftest test-ob-python/insert-necessary-blank-line-when-sending-code-to-interpreter () (ert-deftest test-ob-python/insert-necessary-blank-line-when-sending-code-to-interpreter ()
(org-test-with-temp-text "#+begin_src python :session :results value (should
(equal 2 (org-test-with-temp-text "#+begin_src python :session :results value
if True: if True:
1 1
2 2
#+end_src" #+end_src"
;; Previously, while adding `:session' to a normal code block, also need to add extra blank lines ;; Previously, while adding `:session' to a normal code
;; to end indent block or indicate logical sections. Now, the `org-babel-python-evaluate-session' ;; block, also need to add extra blank lines to end
;; can do it automatically: ;; indent block or indicate logical sections. Now, the
;; >>> if True: ;; `org-babel-python-evaluate-session' can do it
;; >>> 1 ;; automatically:
;; >>> <insert_blank_line_here> ;;
;; >>> 2 ;; >>> if True:
(org-babel-execute-maybe) ;; >>> 1
(should (equal 2 (org-babel-execute-src-block))))) ;; >>> <insert_blank_line_here>
;; >>> 2
(org-babel-execute-maybe)
(org-babel-execute-src-block)))))
(provide 'test-ob-python) (provide 'test-ob-python)
;;; test-ob-python.el ends here ;;; test-ob-python.el ends here

View File

@ -55,49 +55,48 @@
(ert-deftest test-ol/escape () (ert-deftest test-ol/escape ()
"Test `org-link-escape' specifications." "Test `org-link-escape' specifications."
;; No-op when there is no backslash or closing square bracket. ;; No-op when there is no backslash or square bracket.
(should (string= "foo[" (org-link-escape "foo["))) (should (string= "foo" (org-link-escape "foo")))
;; Escape closing square bracket at the end of the link. ;; Escape square brackets at boundaries of the link.
(should (string= "[foo\\]" (org-link-escape "[foo]"))) (should (string= "\\[foo\\]" (org-link-escape "[foo]")))
;; Escape closing square brackets followed by another square ;; Escape square brackets followed by another square bracket.
;; bracket. (should (string= "foo\\]\\[bar" (org-link-escape "foo][bar")))
(should (string= "foo\\][bar" (org-link-escape "foo][bar"))) (should (string= "foo\\]\\]bar" (org-link-escape "foo]]bar")))
(should (string= "foo\\]]bar" (org-link-escape "foo]]bar"))) (should (string= "foo\\[\\[bar" (org-link-escape "foo[[bar")))
;; However, escaping closing square bracket at the end of the link (should (string= "foo\\[\\]bar" (org-link-escape "foo[]bar")))
;; has precedence over the previous rule.
(should (string= "foo]\\]" (org-link-escape "foo]]")))
;; Escape backslashes at the end of the link. ;; Escape backslashes at the end of the link.
(should (string= "foo\\\\" (org-link-escape "foo\\"))) (should (string= "foo\\\\" (org-link-escape "foo\\")))
;; Escape backslashes that could be confused with escaping ;; Escape backslashes that could be confused with escaping
;; characters. ;; characters.
(should (string= "foo\\\\\\]" (org-link-escape "foo\\]"))) (should (string= "foo\\\\\\]" (org-link-escape "foo\\]")))
(should (string= "foo\\\\\\][" (org-link-escape "foo\\]["))) (should (string= "foo\\\\\\]\\[" (org-link-escape "foo\\][")))
(should (string= "foo\\\\\\]]bar" (org-link-escape "foo\\]]bar"))) (should (string= "foo\\\\\\]\\]bar" (org-link-escape "foo\\]]bar")))
;; Do not escape backslash characters when unnecessary. ;; Do not escape backslash characters when unnecessary.
(should (string= "foo\\bar" (org-link-escape "foo\\bar"))) (should (string= "foo\\bar" (org-link-escape "foo\\bar")))
(should (string= "foo\\]bar" (org-link-escape "foo\\]bar")))
;; Pathological cases: consecutive closing square brackets. ;; Pathological cases: consecutive closing square brackets.
(should (string= "[[[foo\\]]\\]" (org-link-escape "[[[foo]]]"))) (should (string= "\\[\\[\\[foo\\]\\]\\]" (org-link-escape "[[[foo]]]")))
(should (string= "[[[foo]\\]] bar" (org-link-escape "[[[foo]]] bar")))) (should (string= "\\[\\[foo\\]\\] bar" (org-link-escape "[[foo]] bar"))))
(ert-deftest test-ol/unescape () (ert-deftest test-ol/unescape ()
"Test `org-link-unescape' specifications." "Test `org-link-unescape' specifications."
;; No-op if there is no backslash. ;; No-op if there is no backslash.
(should (string= "foo[" (org-link-unescape "foo["))) (should (string= "foo" (org-link-unescape "foo")))
;; No-op if backslashes are not escaping backslashes. ;; No-op if backslashes are not escaping backslashes.
(should (string= "foo\\bar" (org-link-unescape "foo\\bar"))) (should (string= "foo\\bar" (org-link-unescape "foo\\bar")))
(should (string= "foo\\]bar" (org-link-unescape "foo\\]bar"))) ;; Unescape backslashes before square brackets.
;; (should (string= "foo]bar" (org-link-unescape "foo\\]bar")))
(should (string= "foo\\]" (org-link-unescape "foo\\\\\\]"))) (should (string= "foo\\]" (org-link-unescape "foo\\\\\\]")))
(should (string= "foo\\][" (org-link-unescape "foo\\\\\\]["))) (should (string= "foo\\][" (org-link-unescape "foo\\\\\\][")))
(should (string= "foo\\]]bar" (org-link-unescape "foo\\\\\\]]bar"))) (should (string= "foo\\]]bar" (org-link-unescape "foo\\\\\\]\\]bar")))
(should (string= "foo\\[[bar" (org-link-unescape "foo\\\\\\[\\[bar")))
(should (string= "foo\\[]bar" (org-link-unescape "foo\\\\\\[\\]bar")))
;; Unescape backslashes at the end of the link. ;; Unescape backslashes at the end of the link.
(should (string= "foo\\" (org-link-unescape "foo\\\\"))) (should (string= "foo\\" (org-link-unescape "foo\\\\")))
;; Unescape closing square bracket at the end of the link. ;; Unescape closing square bracket at boundaries of the link.
(should (string= "[foo]" (org-link-unescape "[foo\\]"))) (should (string= "[foo]" (org-link-unescape "\\[foo\\]")))
;; Pathological cases: consecutive closing square brackets. ;; Pathological cases: consecutive closing square brackets.
(should (string= "[[[foo]]]" (org-link-unescape "[[[foo\\]]\\]"))) (should (string= "[[[foo]]]" (org-link-unescape "\\[\\[\\[foo\\]\\]\\]")))
(should (string= "[[[foo]]] bar" (org-link-unescape "[[[foo]\\]] bar")))) (should (string= "[[foo]] bar" (org-link-unescape "\\[\\[foo\\]\\] bar"))))
(ert-deftest test-ol/make-string () (ert-deftest test-ol/make-string ()
"Test `org-link-make-string' specifications." "Test `org-link-make-string' specifications."
@ -204,11 +203,11 @@
;; Store file link to non-Org buffer, with context. ;; Store file link to non-Org buffer, with context.
(should (should
(let ((org-stored-links nil) (let ((org-stored-links nil)
(org-context-in-file-links t)) (org-link-context-for-files t))
(org-test-with-temp-text-in-file "one\n<point>two" (org-test-with-temp-text-in-file "one\n<point>two"
(fundamental-mode) (fundamental-mode)
(let ((file (buffer-file-name))) (let ((file (buffer-file-name)))
(equal (format "[[file:%s::one]]" file) (equal (format "[[file:%s::two]]" file)
(org-store-link nil)))))) (org-store-link nil))))))
;; Store file link to non-Org buffer, without context. ;; Store file link to non-Org buffer, without context.
(should (should
@ -223,11 +222,11 @@
;; buffer. ;; buffer.
(should (should
(let ((org-stored-links nil) (let ((org-stored-links nil)
(org-context-in-file-links nil)) (org-link-context-for-files nil))
(org-test-with-temp-text-in-file "one\n<point>two" (org-test-with-temp-text-in-file "one\n<point>two"
(fundamental-mode) (fundamental-mode)
(let ((file (buffer-file-name))) (let ((file (buffer-file-name)))
(equal (format "[[file:%s::one]]" file) (equal (format "[[file:%s::two]]" file)
(org-store-link '(4))))))) (org-store-link '(4)))))))
;; A C-u C-u does *not* reverse `org-context-in-file-links' in ;; A C-u C-u does *not* reverse `org-context-in-file-links' in
;; non-Org buffer. ;; non-Org buffer.

View File

@ -576,129 +576,87 @@ CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] => 2:00"
"Test \":link\" parameter in Clock table." "Test \":link\" parameter in Clock table."
;; If there is no file attached to the document, link directly to ;; If there is no file attached to the document, link directly to
;; the headline. ;; the headline.
(let (org-link-descriptive) (should
(should (string-match-p "| +\\[\\[Foo]\\[Foo]] +| 26:00 +|"
(equal (org-test-with-temp-text
"| Headline | Time | "* Foo
|--------------+---------|
| *Total time* | *26:00* |
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* Foo
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t")))) (test-org-clock-clocktable-contents ":link t"))))
;; Otherwise, link to the headline in the current file. ;; Otherwise, link to the headline in the current file.
(should (should
(equal (string-match-p
"| Headline | Time | "| \\[\\[file:filename::Foo]\\[Foo]] +| 26:00 +|"
|-----------------------------+---------| (org-test-with-temp-text
| *Total time* | *26:00* | (org-test-with-temp-text-in-file
|-----------------------------+---------| "* Foo
| [[file:filename::Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
(org-test-with-temp-text-in-file
"* Foo
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(let ((file (buffer-file-name))) (let ((file (buffer-file-name)))
(replace-regexp-in-string (replace-regexp-in-string
(regexp-quote file) "filename" (regexp-quote file) "filename"
(test-org-clock-clocktable-contents ":link t :lang en")))) (test-org-clock-clocktable-contents ":link t :lang en"))))
(org-table-align) (org-table-align)
(buffer-substring-no-properties (point-min) (point-max))))) (buffer-substring-no-properties (point-min) (point-max)))))
;; Ignore TODO keyword, priority cookie, COMMENT and tags in ;; Ignore TODO keyword, priority cookie, COMMENT and tags in
;; headline. ;; headline.
(should (should
(equal (string-match-p
"| Headline | Time | "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|--------------+---------| (org-test-with-temp-text
| *Total time* | *26:00* | "* TODO Foo
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* TODO Foo
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en")))) (test-org-clock-clocktable-contents ":link t :lang en"))))
(should (should
(equal (string-match-p
"| Headline | Time | "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|--------------+---------| (org-test-with-temp-text
| *Total time* | *26:00* | "* [#A] Foo
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* [#A] Foo
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en")))) (test-org-clock-clocktable-contents ":link t :lang en"))))
(should (should
(equal (string-match-p
"| Headline | Time | "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|--------------+---------| (org-test-with-temp-text
| *Total time* | *26:00* | "* COMMENT Foo
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* COMMENT Foo
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t")))) (test-org-clock-clocktable-contents ":link t"))))
(should (should
(equal (string-match-p
"| Headline | Time | "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|--------------+---------| (org-test-with-temp-text
| *Total time* | *26:00* | "* Foo :tag:
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* Foo :tag:
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en")))) (test-org-clock-clocktable-contents ":link t :lang en"))))
;; Remove statistics cookie from headline description. ;; Remove statistics cookie from headline description.
(should (should
(equal (string-match-p
"| Headline | Time | "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|--------------+---------| (org-test-with-temp-text
| *Total time* | *26:00* | "* Foo [50%]
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* Foo [50%]
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en")))) (test-org-clock-clocktable-contents ":link t :lang en"))))
(should (should
(equal (string-match-p
"| Headline | Time | "| \\[\\[Foo]\\[Foo]] +| 26:00 +|"
|--------------+---------| (org-test-with-temp-text
| *Total time* | *26:00* | "* Foo [1/2]
|--------------+---------|
| [[Foo][Foo]] | 26:00 |"
(org-test-with-temp-text
"* Foo [1/2]
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en")))) (test-org-clock-clocktable-contents ":link t :lang en"))))
;; Replace links with their description, or turn them into plain ;; Replace links with their description, or turn them into plain
;; links if there is no description. ;; links if there is no description.
(should (should
(equal (string-match-p
"| Headline | Time | "| \\[\\[Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\\\[Org mode\\\\]\\\\]]\\[Foo Org mode]] +| 26:00 +|"
|-----------------------------------------------------------+---------| (org-test-with-temp-text
| *Total time* | *26:00* | "* Foo [[https://orgmode.org][Org mode]]
|-----------------------------------------------------------+---------|
| [[Foo [[https://orgmode.org\\][Org mode]\\]][Foo Org mode]] | 26:00 |"
(org-test-with-temp-text
"* Foo [[https://orgmode.org][Org mode]]
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en")))) (test-org-clock-clocktable-contents ":link t :lang en"))))
(should (should
(equal (string-match-p
"| Headline | Time | "| \\[\\[Foo \\\\\\[\\\\\\[https://orgmode\\.org\\\\]\\\\]]\\[Foo https://orgmode\\.org]] +| 26:00 +|"
|-----------------------------------------------------------+---------| (org-test-with-temp-text
| *Total time* | *26:00* | "* Foo [[https://orgmode.org]]
|-----------------------------------------------------------+---------|
| [[Foo [[https://orgmode.org]\\]][Foo https://orgmode.org]] | 26:00 |"
(org-test-with-temp-text
"* Foo [[https://orgmode.org]]
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00" CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
(test-org-clock-clocktable-contents ":link t :lang en")))))) (test-org-clock-clocktable-contents ":link t :lang en")))))
(ert-deftest test-org-clock/clocktable/compact () (ert-deftest test-org-clock/clocktable/compact ()
"Test \":compact\" parameter in Clock table." "Test \":compact\" parameter in Clock table."

View File

@ -2439,7 +2439,7 @@ SCHEDULED: <2014-03-04 tue.>"
;; Handle escape characters. ;; Handle escape characters.
(should (should
(org-test-with-temp-text (org-test-with-temp-text
"* H1\n:PROPERTIES:\n:CUSTOM_ID: [%]\n:END:\n* H2\n[[#[%\\]<point>]]" "* H1\n:PROPERTIES:\n:CUSTOM_ID: [%]\n:END:\n* H2\n[[#\\[%\\]<point>]]"
(org-open-at-point) (org-open-at-point)
(looking-at-p "\\* H1"))) (looking-at-p "\\* H1")))
;; Throw an error on false positives. ;; Throw an error on false positives.
@ -2535,7 +2535,7 @@ Foo Bar
(looking-at "\\* TODO COMMENT Test"))) (looking-at "\\* TODO COMMENT Test")))
;; Correctly un-escape fuzzy links. ;; Correctly un-escape fuzzy links.
(should (should
(org-test-with-temp-text "* [foo]\n[[*[foo\\]][With escaped characters]]" (org-test-with-temp-text "* [foo]\n[[*\\[foo\\]][With escaped characters]]"
(org-open-at-point) (org-open-at-point)
(bobp))) (bobp)))
;; Match search strings containing newline characters, including ;; Match search strings containing newline characters, including

View File

@ -3555,7 +3555,7 @@ Another text. (ref:text)
(org-element-map tree 'link 'identity info t) info))))) (org-element-map tree 'link 'identity info t) info)))))
;; Handle escaped fuzzy links. ;; Handle escaped fuzzy links.
(should (should
(org-test-with-parsed-data "* [foo]\n[[[foo\\]]]" (org-test-with-parsed-data "* [foo]\n[[\\[foo\\]]]"
(org-export-resolve-fuzzy-link (org-export-resolve-fuzzy-link
(org-element-map tree 'link #'identity info t) info)))) (org-element-map tree 'link #'identity info t) info))))