forked from mirrors/org-mode
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:
parent
fe67cebb3a
commit
ad62379984
17
lisp/ox.el
17
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
|
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)
|
||||||
alist))))
|
(read (current-buffer))) ; moves point
|
||||||
|
alist))))
|
||||||
alist))
|
alist))
|
||||||
;; Priority is given to back-end specific options.
|
;; Priority is given to back-end specific options.
|
||||||
(all (append (org-export-get-all-options backend)
|
(all (append (org-export-get-all-options backend)
|
||||||
|
|
|
@ -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."
|
||||||
|
|
Loading…
Reference in New Issue