mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-05 06:12:59 +00:00
org-babel-read: Read quotes strings ignoring leading/trailing newlines
* lisp/ob-core.el (org-babel-read): When reading "string", ignore leading/trailing newlines in addition to spaces. * testing/lisp/test-ob.el (test-ob/org-babel-read): Add more tests. Reported-by: Max Nikulin <manikulin@gmail.com> Link: https://orgmode.org/list/v15lva$hhl$1@ciao.gmane.io
This commit is contained in:
parent
edb5eaaac3
commit
0227e12605
|
@ -3363,9 +3363,9 @@ situations in which is it not appropriate."
|
||||||
((let (read-val)
|
((let (read-val)
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(and (string-match
|
(and (string-match
|
||||||
(rx bos (0+ space)
|
(rx bos (0+ (any space ?\n))
|
||||||
?\" (0+ anychar) ?\"
|
?\" (0+ anychar) ?\"
|
||||||
(0+ space) eos)
|
(0+ (any space ?\n)) eos)
|
||||||
cell)
|
cell)
|
||||||
;; CELL is a single string
|
;; CELL is a single string
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
|
|
@ -2554,6 +2554,7 @@ abc
|
||||||
(should (equal 1.2 (org-babel-read "1.2" inhibit)))
|
(should (equal 1.2 (org-babel-read "1.2" inhibit)))
|
||||||
;; Allow whitespace
|
;; Allow whitespace
|
||||||
(should (equal 1 (org-babel-read " 1 " inhibit)))
|
(should (equal 1 (org-babel-read " 1 " inhibit)))
|
||||||
|
(should (equal 1 (org-babel-read " 1\n" inhibit)))
|
||||||
;; Not a number
|
;; Not a number
|
||||||
(should-not (equal 1 (org-babel-read "1foo" inhibit)))
|
(should-not (equal 1 (org-babel-read "1foo" inhibit)))
|
||||||
;; Empty string
|
;; Empty string
|
||||||
|
@ -2598,12 +2599,15 @@ abc
|
||||||
(org-babel-read "*this*" inhibit))))
|
(org-babel-read "*this*" inhibit))))
|
||||||
;; Special case: data inside quotes
|
;; Special case: data inside quotes
|
||||||
(should (equal "foo" (org-babel-read " \"foo\" " inhibit)))
|
(should (equal "foo" (org-babel-read " \"foo\" " inhibit)))
|
||||||
|
(should (equal "foo" (org-babel-read " \"foo\"\n" inhibit)))
|
||||||
(should (equal "foo with\" inside" (org-babel-read " \"foo with\\\" inside\" " inhibit)))
|
(should (equal "foo with\" inside" (org-babel-read " \"foo with\\\" inside\" " inhibit)))
|
||||||
(should (equal "abc\nsdf" (org-babel-read "\"abc\nsdf\"" inhibit)))
|
(should (equal "abc\nsdf" (org-babel-read "\"abc\nsdf\"" inhibit)))
|
||||||
(should (equal "foo" (org-babel-read "\"foo\"" inhibit)))
|
(should (equal "foo" (org-babel-read "\"foo\"" inhibit)))
|
||||||
(should (equal "\"foo\"(\"bar\"" (org-babel-read "\"foo\"(\"bar\"" inhibit)))
|
(should (equal "\"foo\"(\"bar\"" (org-babel-read "\"foo\"(\"bar\"" inhibit)))
|
||||||
;; Unpaired quotes
|
;; Unpaired quotes
|
||||||
(should (equal "\"foo\"\"bar\"" (org-babel-read "\"foo\"\"bar\"" inhibit)))))
|
(should (equal "\"foo\"\"bar\"" (org-babel-read "\"foo\"\"bar\"" inhibit)))
|
||||||
|
;; Recover from `read' parsing errors.
|
||||||
|
(org-babel-read "\"Quoted closing quote:\\\"" inhibit)))
|
||||||
|
|
||||||
(ert-deftest test-ob/demarcate-block-split-duplication ()
|
(ert-deftest test-ob/demarcate-block-split-duplication ()
|
||||||
"Test duplication of language, body, switches, and headers in splitting."
|
"Test duplication of language, body, switches, and headers in splitting."
|
||||||
|
|
Loading…
Reference in a new issue