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é <pierrebalaye@gmail.com>
Link: https://list.orgmode.org/orgmode/CANpQAF-n+4xhNvL8aaP8j2gJ70vbu80wmh9a4Oj0BxNHA5-yDA@mail.gmail.com/
This commit is contained in:
Ihor Radchenko 2022-11-17 12:49:29 +08:00
parent fe67cebb3a
commit ad62379984
No known key found for this signature in database
GPG Key ID: 6470762A7DA11D8B
2 changed files with 13 additions and 9 deletions

View File

@ -1404,13 +1404,14 @@ Optional argument BACKEND is an export back-end, as returned by,
e.g., `org-export-create-backend'. It specifies which back-end e.g., `org-export-create-backend'. It specifies which back-end
specific items to read, if any." specific items to read, if any."
(let ((line (let ((line
(let ((s 0) alist) (let (value alist)
(while (string-match "\\(.+?\\):\\((.*?)\\|\\S-+\\)?[ \t]*" options s) (with-temp-buffer
(setq s (match-end 0)) (insert options)
(let ((value (match-string 2 options))) (goto-char (point-min))
(when value (while (re-search-forward "\\s-*\\(.+?\\):" nil t)
(push (cons (match-string 1 options) (when (looking-at-p "\\S-")
(read value)) (push (cons (match-string 1)
(read (current-buffer))) ; moves point
alist)))) alist))))
alist)) alist))
;; Priority is given to back-end specific options. ;; Priority is given to back-end specific options.

View File

@ -198,7 +198,10 @@ num:2 <:active")))
(should (should
(let ((options (org-export--parse-option-keyword "H: num:t"))) (let ((options (org-export--parse-option-keyword "H: num:t")))
(and (not (plist-get options :headline-levels)) (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 () (ert-deftest test-org-export/get-inbuffer-options ()
"Test reading all standard export keywords." "Test reading all standard export keywords."