mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-23 07:18:53 +00:00
fixed bug in parsing of arguments to code block references
* lisp/ob-ref.el (org-babel-ref-split-args): Now uses `org-babel-balanced-split'. * testing/lisp/test-ob.el (test-ob/splitting-variable-lists-in-references): Test new working behavior.
This commit is contained in:
parent
4ecf626ee7
commit
b21da5f5d6
@ -244,20 +244,7 @@ to \"0:-1\"."
|
||||
|
||||
(defun org-babel-ref-split-args (arg-string)
|
||||
"Split ARG-STRING into top-level arguments of balanced parenthesis."
|
||||
(let ((index 0) (depth 0) (buffer "") holder return)
|
||||
;; crawl along string, splitting at any ","s which are on the top level
|
||||
(while (< index (length arg-string))
|
||||
(setq holder (substring arg-string index (+ 1 index)))
|
||||
(setq buffer (concat buffer holder))
|
||||
(setq index (+ 1 index))
|
||||
(cond
|
||||
((string= holder ",")
|
||||
(when (= depth 0)
|
||||
(setq return (cons (substring buffer 0 -1) return))
|
||||
(setq buffer "")))
|
||||
((or (string= holder "(") (string= holder "[")) (setq depth (+ depth 1)))
|
||||
((or (string= holder ")") (string= holder "]")) (setq depth (- depth 1)))))
|
||||
(mapcar #'org-babel-trim (reverse (cons buffer return)))))
|
||||
(mapcar #'org-babel-trim (org-babel-balanced-split arg-string 44)))
|
||||
|
||||
(defvar org-bracket-link-regexp)
|
||||
(defun org-babel-ref-at-ref-p ()
|
||||
|
@ -576,6 +576,13 @@ on two lines
|
||||
#+end_src"
|
||||
(should (string= (org-babel-expand-noweb-references) "barbaz"))))
|
||||
|
||||
(ert-deftest test-ob/splitting-variable-lists-in-references ()
|
||||
(org-test-with-temp-text ""
|
||||
(should (= 1 (length (org-babel-ref-split-args
|
||||
"a=\"this, no work\""))))
|
||||
(should (= 2 (length (org-babel-ref-split-args
|
||||
"a=\"this, no work\", b=1"))))))
|
||||
|
||||
(provide 'test-ob)
|
||||
|
||||
;;; test-ob ends here
|
||||
|
Loading…
Reference in New Issue
Block a user