org-element: Allow duals keywords with only secondary value

* lisp/org-element.el (org-element--collect-affiliated-keywords):
  Allow duals keywords with only secondary value.
* testing/lisp/test-org-element.el: Add test.

This patch allows to parse correctly the following:

    #+CAPTION[short caption]:
    #+CAPTION: Very long caption
    Some paragraph.
This commit is contained in:
Nicolas Goaziou 2012-10-28 22:43:50 +01:00
parent f6e936c2b9
commit 98d5666bac
2 changed files with 7 additions and 1 deletions

View File

@ -3822,7 +3822,8 @@ position of point and CDR is nil."
;; Now set final shape for VALUE.
(when parsedp
(setq value (org-element-parse-secondary-string value restrict)))
(when dualp (setq value (and value (cons value dual-value))))
(when dualp
(setq value (and (or value dual-value) (cons value dual-value))))
(when (or (member kwd org-element-multiple-keywords)
;; Attributes can always appear on multiple lines.
(string-match "^ATTR_" kwd))

View File

@ -208,6 +208,11 @@ Some other text
(equal
'((("l2") "s2") (("l1") "s1"))
(org-test-with-temp-text "#+CAPTION[s1]: l1\n#+CAPTION[s2]: l2\nParagraph"
(org-element-property :caption (org-element-at-point)))))
(should
(equal
'((("l1")) (nil "s1"))
(org-test-with-temp-text "#+CAPTION[s1]:\n#+CAPTION: l1\nParagraph"
(org-element-property :caption (org-element-at-point))))))