branch: externals/org commit ad623799849177cc837e344d89bbfc654bf389dd Author: Ihor Radchenko <yanta...@posteo.net> Commit: Ihor Radchenko <yanta...@posteo.net>
org-export: Allow "string with spaces" as #+OPTIONS: values * lisp/ox.el (org-export--parse-option-keyword): Allow `read'ing the option value as far as needed. Do not restrict the value to the first whitespace only. This way, one can use Elisp strings with all the escaping options as values. * testing/lisp/test-ox.el (test-org-export/parse-option-keyword): Add test for option value with a space inside. Reported-by: Pierre BalayƩ <pierrebal...@gmail.com> Link: https://list.orgmode.org/orgmode/canpqaf-n+4xhnvl8aap8j2gj70vbu80wmh9a4oj0bxnha5-...@mail.gmail.com/ --- lisp/ox.el | 17 +++++++++-------- testing/lisp/test-ox.el | 5 ++++- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lisp/ox.el b/lisp/ox.el index 770f867402..c1a1ad83ed 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -1404,14 +1404,15 @@ Optional argument BACKEND is an export back-end, as returned by, e.g., `org-export-create-backend'. It specifies which back-end specific items to read, if any." (let ((line - (let ((s 0) alist) - (while (string-match "\\(.+?\\):\\((.*?)\\|\\S-+\\)?[ \t]*" options s) - (setq s (match-end 0)) - (let ((value (match-string 2 options))) - (when value - (push (cons (match-string 1 options) - (read value)) - alist)))) + (let (value alist) + (with-temp-buffer + (insert options) + (goto-char (point-min)) + (while (re-search-forward "\\s-*\\(.+?\\):" nil t) + (when (looking-at-p "\\S-") + (push (cons (match-string 1) + (read (current-buffer))) ; moves point + alist)))) alist)) ;; Priority is given to back-end specific options. (all (append (org-export-get-all-options backend) diff --git a/testing/lisp/test-ox.el b/testing/lisp/test-ox.el index 42867919b4..a78cc727c1 100644 --- a/testing/lisp/test-ox.el +++ b/testing/lisp/test-ox.el @@ -198,7 +198,10 @@ num:2 <:active"))) (should (let ((options (org-export--parse-option-keyword "H: num:t"))) (and (not (plist-get options :headline-levels)) - (plist-get options :section-numbers))))) + (plist-get options :section-numbers)))) + ;; Parse spaces inside brackets. + (let ((options (org-export--parse-option-keyword "html-postamble:\"test space\"" 'html))) + (should (equal "test space" (plist-get options :html-postamble))))) (ert-deftest test-org-export/get-inbuffer-options () "Test reading all standard export keywords."